newContext method

  1. @override
Future<DbContext> newContext()
override

Implementation

@override
Future<DbContext> newContext() async {
  late DatabaseExecutor sqfDb;
  var onConfig = (d) async {
    await d.execute('PRAGMA foreign_keys = ON;');
  };

  if(Platform.isIOS || Platform.isAndroid || Platform.isMacOS) {
    sqfDb = await openDatabase(_path, onConfigure: onConfig);
  }
  else {
    sqfDb = await databaseFactoryFfi.openDatabase(_path, options: OpenDatabaseOptions(onConfigure: onConfig));
  }
  return SqliteDbContext(sqfDb);
}