@@ -383,10 +383,11 @@ class Store {
383383 }
384384
385385 // Isolate entry point must be static or top-level.
386- static void _callFunctionWithStoreInIsolate <P , R >(IsoPass <P , R > isoPass) {
386+ static Future <void > _callFunctionWithStoreInIsolate <P , R >(
387+ IsoPass <P , R > isoPass) async {
387388 final store = Store .attach (isoPass.model, isoPass.dbDirectoryPath,
388389 queriesCaseSensitiveDefault: isoPass.queriesCaseSensitiveDefault);
389- final result = isoPass.runFn (store);
390+ final result = await isoPass.runFn (store);
390391 store.close ();
391392 // Note: maybe replace with Isolate.exit once min Dart SDK 2.15.
392393 isoPass.resultPort? .send (result);
@@ -398,7 +399,7 @@ class Store {
398399 /// Instances of [callback] must be top-level functions or static methods
399400 /// of classes, not closures or instance methods of objects.
400401 Future <R > runIsolated <P , R >(
401- TxMode mode, R Function (Store , P ) callback, P param) async {
402+ TxMode mode, FutureOr < R > Function (Store , P ) callback, P param) async {
402403 final resultPort = ReceivePort ();
403404 // Await isolate spawn to avoid waiting forever if it fails to spawn.
404405 await Isolate .spawn (
@@ -550,7 +551,7 @@ class IsoPass<P, R> {
550551 final P param;
551552
552553 /// Function to be called in isolate
553- final R Function (Store , P ) fn;
554+ final FutureOr < R > Function (Store , P ) fn;
554555
555556 /// creates everything that needs to be passed to the isolate.
556557 const IsoPass (
@@ -563,5 +564,5 @@ class IsoPass<P, R> {
563564 this .param);
564565
565566 /// Called inside this class so types are not lost (dynamic instead of P and R).
566- R runFn (Store store) => fn (store, param);
567+ FutureOr < R > runFn (Store store) => fn (store, param);
567568}
0 commit comments