use a Drawercontext to be able to have a specific scaffold for each page
This commit is contained in:
@ -28,7 +28,7 @@ class Db {
|
||||
// Set the path to the database. Note: Using the `join` function from the
|
||||
// `path` package is best practice to ensure the path is correctly
|
||||
// constructed for each platform.
|
||||
join(await getDatabasesPath(), 'previews.db'),
|
||||
dbpath,
|
||||
onCreate: (db, version) {
|
||||
// Run the CREATE TABLE statement on the database.
|
||||
return db.execute(
|
||||
@ -41,6 +41,22 @@ class Db {
|
||||
);
|
||||
}
|
||||
|
||||
/// delete all data but keep structure
|
||||
Future<void> clear() async {
|
||||
await _db.delete("previews");
|
||||
// shrink the db file size
|
||||
await _db.execute("VACUUM");
|
||||
}
|
||||
|
||||
/// get db size in bytes
|
||||
Future<int> getDbSize() async {
|
||||
final int cnt = (await Db().db().rawQuery("pragma page_count;"))[0]
|
||||
["page_count"] as int;
|
||||
final int pagesize =
|
||||
(await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int;
|
||||
return cnt * pagesize;
|
||||
}
|
||||
|
||||
Database db() {
|
||||
return _db;
|
||||
}
|
||||
|
Reference in New Issue
Block a user