diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /lib/model/db/db_extension.dart | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'lib/model/db/db_extension.dart')
| -rw-r--r-- | lib/model/db/db_extension.dart | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/model/db/db_extension.dart b/lib/model/db/db_extension.dart new file mode 100644 index 0000000..a0d2a66 --- /dev/null +++ b/lib/model/db/db_extension.dart @@ -0,0 +1,13 @@ +import 'package:sqflite/sqflite.dart'; + +extension ExtraDatabase on Database { + // check table existence via `sqlite_master` + // `sqlite_schema` is the alias used in SQLite documentation, + // but it was introduced in SQLite v3.33.0 and it is unavailable on Android API < 34, + // and the historical alias `sqlite_master` is still supported. + // cf https://www.sqlite.org/faq.html#q7 + Future<bool> tableExists(String table) async { + final results = await query('sqlite_master', where: 'type = ? AND name = ?', whereArgs: ['table', table]); + return results.isNotEmpty; + } +} |
