Open AnilNeodove opened 10 months ago
Yes I'm facing the same
Have u resolved it?
I've resolved it by using the following line in isolate entry function.
BackgroundIsolateBinaryMessenger.ensureInitialized(args[1]);
And
RootIsolateToken
For Expamle
Inside main -
/// Initialize Isolates
final rootIsolateToken = RootIsolateToken.instance;
if (rootIsolateToken == null) {
Logger.instance.writeLogs("main - rootIsolateToken", "Cannot get the RootIsolateToken", LogLevel.error);
return;
}
await Isolate.spawn(
dbIsolateEntry, [mainSendPort, rootIsolateToken]);
static void dbIsolateEntry(List<dynamic> args) async {
final dbReceivePort = ReceivePort();
final dbSendPort = dbReceivePort.sendPort;
BackgroundIsolateBinaryMessenger.ensureInitialized(args[1]);
// initialize database
await DatabaseProvider().database;
await for (final BaseIsolateMessage message in dbReceivePort) {
// listen for messages
}
}
i want to use database in seperate isolates but getting error.
databaseFactory is only initialized when using sqflite. When using
sqflite_common_ffi
You must calldatabaseFactory = databaseFactoryFfi;
before using global openDatabase APIanyone is facing same issue