initDataBase static method

LazyDatabase initDataBase()

Implementation

static LazyDatabase initDataBase() {
  return LazyDatabase(() async {
    final version = AppState().version.split('.').toList().join();
    final cachedPath = path.join(
      (await getApplicationDocumentsDirectory()).path,
      'CloryDB$version.db',
    );
    if (!await File(cachedPath).exists()) {
      final dbPath = await rootBundle.load('assets/databases/CloryDB.db');
      await File(cachedPath).writeAsBytes(dbPath.buffer.asUint8List());
    }
    sqlite3.tempDirectory = (await getTemporaryDirectory()).path;
    return NativeDatabase.createInBackground(File(cachedPath));
  });
}