idb_sqflite 1.3.2 copy "idb_sqflite: ^1.3.2" to clipboard
idb_sqflite: ^1.3.2 copied to clipboard

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

example/main.dart

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;
}
43
likes
140
pub points
77%
popularity

Publisher

verified publishertekartik.com

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

Repository (GitHub)
View/report issues

Topics

#database

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

idb_shim, meta, sqflite_common

More

Packages that depend on idb_sqflite