From 01bb3f5b50c74375b7f7e7cf0173dc3c45f7bcf9 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Wed, 14 Oct 2020 12:13:57 +0200 Subject: [PATCH] fix: Make key backup work in web --- lib/src/utils/run_in_background.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/utils/run_in_background.dart b/lib/src/utils/run_in_background.dart index cbc5a40..8d837bb 100644 --- a/lib/src/utils/run_in_background.dart +++ b/lib/src/utils/run_in_background.dart @@ -21,7 +21,13 @@ import 'dart:async'; Future runInBackground( FutureOr Function(U arg) function, U arg) async { - final isolate = await IsolateRunner.spawn(); + IsolateRunner isolate; + try { + isolate = await IsolateRunner.spawn(); + } on UnsupportedError { + // web does not support isolates (yet), so we fall back to calling the method directly + return await function(arg); + } try { return await isolate.run(function, arg); } finally {