From f1579a5f0f6beb41318d87ca1db268d71bda65a5 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 19 Jun 2020 15:28:03 +0200 Subject: [PATCH] Database transaction workaround --- lib/src/database/database.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index 8abde1df..28ea9d1e 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -20,6 +20,18 @@ class Database extends _$Database { int get maxFileSize => 1 * 1024 * 1024; + @override + Future transaction(Future Function() action) async { + try { + await super.transaction(() async { + await customSelect('SELECT 1').get(); + }); + } catch (_) { + return action(); + } + return super.transaction(action); + } + @override MigrationStrategy get migration => MigrationStrategy( onCreate: (Migrator m) {