import 'dart:io'; import 'package:sqflite/sqflite.dart'; import 'path.dart'; class NoteFile { late Database _db; String filepath; Database db() { return _db; } NoteFile(this.filepath); Future init() async { final path = (await getSavePath()).path + Platform.pathSeparator + filepath; _db = await openDatabase( path, onCreate: (db, version) { return db.execute( 'CREATE TABLE strokes(id integer primary key autoincrement, color INTEGER, elevation INTEGER);' 'CREATE TABLE points(id integer primary key autoincrement, x INTEGER, y INTEGER, thickness REAL, strokeid INTEGER)', ); }, // Set the version. This executes the onCreate function and provides a // path to perform database upgrades and downgrades. version: 1, ); } void delete() { // todo remove db file } Future close() async { // shrink the db file size await _db.execute('VACUUM'); _db.close(); } }