initDataBase static method

LazyDatabase initDataBase()

Implementation

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