squash pdf export + storage permissions

This commit is contained in:
2022-10-31 18:29:58 +00:00
parent 84eef41996
commit 004b7166f7
13 changed files with 207 additions and 31 deletions

View File

@@ -18,11 +18,18 @@ class NoteFile {
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)',
);
onCreate: (db, version) async {
Batch batch = db.batch();
batch.execute('DROP TABLE IF EXISTS strokes;');
batch.execute('DROP TABLE IF EXISTS points;');
batch.execute(
'CREATE TABLE strokes(id integer primary key autoincrement, color INTEGER, elevation INTEGER)');
batch.execute(
'CREATE TABLE points(id integer primary key autoincrement, x INTEGER, y INTEGER, thickness REAL, strokeid INTEGER)');
await batch.commit();
return;
},
// Set the version. This executes the onCreate function and provides a
// path to perform database upgrades and downgrades.

View File

@@ -7,8 +7,11 @@ Future<Directory> getSavePath() async {
Directory dbpath;
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS) {
final dir =
(await getExternalStorageDirectory())?.parent.parent.parent.parent ??
(await getApplicationDocumentsDirectory());
dbpath = Directory(
'${(await getApplicationDocumentsDirectory()).path}${Platform.pathSeparator}notes');
'${dir.path}${Platform.pathSeparator}Documents${Platform.pathSeparator}notes');
} else {
dbpath = Directory(
'${(await getApplicationDocumentsDirectory()).path}${Platform.pathSeparator}notes');