idb_sqflite 1.3.3+3 copy "idb_sqflite: ^1.3.3+3" to clipboard
idb_sqflite: ^1.3.3+3 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;
}
44
likes
0
points
243
downloads

Publisher

verified publishertekartik.com

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

Topics

#database

License

unknown (license)

Dependencies

idb_shim, meta, sqflite_common, synchronized

More

Packages that depend on idb_sqflite