sqlite3_web 0.3.1 copy "sqlite3_web: ^0.3.1" to clipboard
sqlite3_web: ^0.3.1 copied to clipboard

Platformweb

Utilities to simplify accessing sqlite3 on the web, with automated feature detection.

example/main.dart

import 'dart:js_interop';
import 'dart:js_interop_unsafe';

import 'package:sqlite3_web/sqlite3_web.dart';

void main() async {
  final sqlite = WebSqlite.open(
    worker: Uri.parse('worker.dart.js'),
    wasmModule: Uri.parse('sqlite3.wasm'),
  );

  final features = await sqlite.runFeatureDetection();
  print('got features: $features');

  globalContext['open'] =
      (JSString name, JSString storage, JSString accessMode) {
    return Future(() async {
      final database = await sqlite.connect(
          name.toDart,
          StorageMode.values.byName(storage.toDart),
          AccessMode.values.byName(accessMode.toDart));

      database.updates.listen((update) {
        print('Update on $name: $update');
      });

      return database.toJSBox;
    }).toJS;
  }.toJS;

  globalContext['execute'] = (JSBoxedDartObject database, JSString sql) {
    return Future(() async {
      await (database.toDart as Database).execute(sql.toDart);
    }).toJS;
  }.toJS;
}
2
likes
160
points
21.8k
downloads

Publisher

verified publishersimonbinder.eu

Weekly Downloads

Utilities to simplify accessing sqlite3 on the web, with automated feature detection.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

sqlite3, stream_channel, web

More

Packages that depend on sqlite3_web