Working on linux and web
This commit is contained in:
parent
d9dd3cd7aa
commit
4fe82dc3db
5 changed files with 30146 additions and 5 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import 'package:drift/drift.dart';
|
||||
import 'package:drift/web.dart';
|
||||
import 'package:drift/wasm.dart';
|
||||
|
||||
|
||||
LazyDatabase openConnection() {
|
||||
return LazyDatabase(() async {
|
||||
// For web, use the web implementation
|
||||
return WebDatabase.withStorage(
|
||||
await DriftWebStorage.indexedDb('formulas_db'),
|
||||
final db = await WasmDatabase.open(
|
||||
databaseName: 'd4rt_formulas',
|
||||
sqlite3Uri: Uri.parse('sqlite3.wasm'),
|
||||
driftWorkerUri: Uri.parse('drift_worker.js'),
|
||||
);
|
||||
|
||||
return db.resolvedExecutor;
|
||||
|
||||
});
|
||||
}
|
||||
30129
web/drift_worker.js
Normal file
30129
web/drift_worker.js
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -34,6 +34,5 @@
|
|||
</head>
|
||||
<body>
|
||||
<script src="flutter_bootstrap.js" async></script>
|
||||
<script src="sql-wasm.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
BIN
web/sqlite3.wasm
Normal file
BIN
web/sqlite3.wasm
Normal file
Binary file not shown.
9
web/worker.dart
Normal file
9
web/worker.dart
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import 'package:drift/wasm.dart';
|
||||
|
||||
/// This Dart program is the entrypoint of a web worker that will be compiled to
|
||||
/// JavaScript by running `build_runner build`. The resulting JavaScript file
|
||||
/// (`shared_worker.dart.js`) is part of the build result and will be shipped
|
||||
/// with the rest of the application when running or building a Flutter web app.
|
||||
void main() {
|
||||
return WasmDatabase.workerMainForOpen();
|
||||
}
|
||||
Loading…
Reference in a new issue