loadFromUrl static method
Future<WasmSqlite3>
loadFromUrl(
- Uri uri, {
- Map<
String, String> ? headers, - WasmModuleLoader? loader,
Loads a web version of the sqlite3 libraries.
The native wasm library for sqlite3 is loaded from the uri with the
desired headers through a fetch request.
Implementation
static Future<WasmSqlite3> loadFromUrl(
Uri uri, {
Map<String, String>? headers,
WasmModuleLoader? loader,
}) async {
web.RequestInit? options;
if (headers != null) {
final headersJs = JSObject();
headers.forEach((key, value) {
headersJs[key] = value.toJS;
});
options = web.RequestInit(headers: headersJs);
}
final jsUri = uri.isAbsolute
? web.URL(uri.toString())
: web.URL(uri.toString(), Uri.base.toString());
final response = await fetch(jsUri, options).toDart;
return _load(response, loader);
}