Last updated:
0 purchases
idb sqflite
idb_sqflite #
Indexed DB for flutter on top of sqflite.
Supports both iOS and Android
Supports Flutter Web through idb_shim.
Supports Dart VM (Desktop) through idb_shim
Example #
Simple notepad available here running on
Flutter (iOS/Android/Web).
Getting Started #
import 'package:idb_sqflite/idb_sqflite.dart';
import 'package:sqflite/sqflite.dart';
Future main() async {
// The sqflite flutter factory
var factory = getIdbFactorySqflite(databaseFactory);
// define the store name
const String storeName = "records";
// open the database
Database db = await factory.open("my_records.db", version: 1,
onUpgradeNeeded: (VersionChangeEvent event) {
Database db = event.database;
// create the store
db.createObjectStore(storeName, autoIncrement: true);
});
// put some data
var txn = db.transaction(storeName, idbModeReadWrite);
var store = txn.objectStore(storeName);
var key = await store.put({"some": "data"});
await txn.completed;
// read some data
txn = db.transaction(storeName, idbModeReadOnly);
store = txn.objectStore(storeName);
var value = await store.getObject(key);
print(value);
await txn.completed;
}
copied to clipboard
See idb_shim for API usage or more generally the
W3C reference
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.