-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
const statsIntervalPreference = "STATS_INTERVAL_PREFERENCE"; | ||
const appThemeMode = "APP_THEME_MODE"; | ||
const dbFileName = "habbit_tracker.sqlite"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
import 'package:drift/web.dart'; | ||
import 'package:drift/drift.dart'; | ||
import 'package:drift/wasm.dart'; | ||
|
||
import '../helpers/constants.dart'; | ||
import './core.dart'; | ||
|
||
DatabaseConnection connectOnWeb() { | ||
return DatabaseConnection.delayed(Future(() async { | ||
final result = await WasmDatabase.open( | ||
databaseName: dbFileName, | ||
sqlite3Uri: Uri.parse('sqlite3.wasm'), | ||
driftWorkerUri: Uri.parse('drift_worker.dart.js'), | ||
); | ||
|
||
if (result.missingFeatures.isNotEmpty) { | ||
// Depending how central local persistence is to your app, you may want | ||
// to show a warning to the user if only unrealiable implemetentations | ||
// are available. | ||
// print('Using ${result.chosenImplementation} due to missing browser ' | ||
// 'features: ${result.missingFeatures}'); | ||
} | ||
|
||
return result.resolvedExecutor; | ||
})); | ||
} | ||
|
||
SharedDatabase constructDb() { | ||
return SharedDatabase(WebDatabase('db')); | ||
return SharedDatabase(connectOnWeb()); | ||
} |