File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Dart imports:
2+ import 'dart:io' ;
3+
14// Package imports:
5+ import 'package:path/path.dart' ;
6+ import 'package:path_provider/path_provider.dart' ;
27import 'package:sqflite/sqflite.dart' ;
38
49// Project imports:
@@ -74,8 +79,17 @@ class MyLibraryDb {
7479 }
7580
7681 Future <Database > _initDatabase () async {
77- final databasePath = await getDatabasesPath ();
78- final path = '$databasePath /mylibrary.db' ;
82+ String databasePath;
83+ if (Platform .isWindows || Platform .isLinux || Platform .isMacOS) {
84+ final directory = await getApplicationSupportDirectory ();
85+ databasePath = directory.path;
86+ try {
87+ await Directory (databasePath).create (recursive: true );
88+ } catch (_) {}
89+ } else {
90+ databasePath = await getDatabasesPath ();
91+ }
92+ final path = join (databasePath, 'mylibrary.db' );
7993
8094 return await openDatabase (
8195 path,
You can’t perform that action at this time.
0 commit comments