Closed asa767 closed 2 months ago
If it works with debug builds but not after deploying, isn't it possible that something went wrong in the deployment step? Do you see any errors in the console? Looking at network requests happening while opening your website, it doesn't even appear to attempt loading a glossary.db
. Can you share the code you use to open the database on the web?
The code I used to import database is as below:
import 'dart:async';
import 'package:drift/drift.dart';
import 'package:drift/wasm.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show rootBundle;
/// Obtains a database connection for running drift on the web.
DatabaseConnection connect() {
return DatabaseConnection.delayed(Future(() async {
final db = await WasmDatabase.open(
databaseName: 'glossary.db',
sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('drift_worker.js'),
initializeDatabase: () async {
final data = await rootBundle.load('assets/glossary.db');
return data.buffer.asUint8List();
},
);
if (db.missingFeatures.isNotEmpty) {
debugPrint('Using ${db.chosenImplementation} due to unsupported '
'browser features: ${db.missingFeatures}');
}
return db.resolvedExecutor;
}));
}
After typing the 3rd letter at searchbox (i.e."qadar", "creator") my program tries to load db. The error I got is above. I checked the permissions for the glossary.db file as "0644".
I think I solved the issue by changing the asset db's file extension from ".db" to ".sqlite". By this fix, "glossary.sqlite" served as "Content-Type:application/octet-stream". Before it was "Content-Type:text/html".
Glad that you got it working! I think it's kind of shocking that .db
files would be served as text/html
, but if your server is perhaps transforming these files then it makes sense that they wouldn't be imported correctly. I'll close this issue then since it appears to be specific to your server/CDN.
Hi,
I have developed a glossary app. It worked on android and on iOS perfectly. It also worked well on web at debug time. But when I get a build for web and uploaded to my test server, It stopped working.
I am using a prefilled glossary.db (sqlite file), it is under assets. Debug time I can see the data that served in glossary.db on "flutter run web". But at the test server (https://test.medreseradyo.com) it returns nothing. You may check the server if you wish.
Thanks for the library and thanks for your support.