idb_sqflite 1.3.6+2 copy "idb_sqflite: ^1.3.6+2" to clipboard
idb_sqflite: ^1.3.6+2 copied to clipboard

IndexedDB API on top of sqflite for Flutter (Desktop and Mobile) and DartVM io applications

example/main.dart

// ignore_for_file: avoid_print

import 'package:idb_sqflite/idb_sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

Future main() async {
  // The sqflite base factory

  var factory = getIdbFactorySqflite(databaseFactoryFfi);
  // define the store name
  const storeName = 'records';

  // open the database
  var db = await factory.open(
    'my_records.db',
    version: 1,
    onUpgradeNeeded: (VersionChangeEvent event) {
      var db = event.database;
      // create the store
      db.createObjectStore(storeName, autoIncrement: true);
    },
  );

  // put some data
  var txn = db.transaction(storeName, 'readwrite');
  var store = txn.objectStore(storeName);
  var key = await store.put({'some': 'data'});
  await txn.completed;

  // read some data
  txn = db.transaction(storeName, 'readonly');
  store = txn.objectStore(storeName);
  var value = await store.getObject(key);

  print(value);
  await txn.completed;
}
46
likes
160
points
595
downloads

Documentation

API reference

Publisher

verified publishertekartik.com

Weekly Downloads

IndexedDB API on top of sqflite for Flutter (Desktop and Mobile) and DartVM io applications

Repository (GitHub)
View/report issues

Topics

#database

License

BSD-2-Clause (license)

Dependencies

idb_shim, meta, sqflite_common, synchronized

More

Packages that depend on idb_sqflite