idb_sqflite 0.1.0+3
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';
Future main() async {
// The sqflite base factory
var factory = idbFactorySqflite;
// 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;
}
See idb_shim for API usage or more generally the W3C reference
0.1.0+3 #
- Initial revision
import 'package:idb_sqflite/idb_sqflite.dart';
Future main() async {
// The sqflite base factory
var factory = idbFactorySqflite;
// 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, "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;
}
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
idb_sqflite: ^0.1.0+3
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:idb_sqflite/idb_sqflite.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
65
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
82
|
Learn more about scoring.
We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.13.1+4
- Flutter: 1.12.13+hotfix.2
Health suggestions
Fix lib/src/sqflite_cursor.dart
. (-0.50 points)
Analysis of lib/src/sqflite_cursor.dart
reported 1 hint:
line 253 col 38: The declaration '_rows' isn't referenced.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.4.0-dev.0 <3.0.0 | ||
flutter | 0.0.0 | ||
idb_shim | >=1.10.0-dev <2.0.0 | 1.10.2 | |
meta | >=1.1.6 <3.0.0 | 1.1.8 | |
sqflite | >=1.1.6+4 <2.0.0 | 1.1.7+3 | |
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
js | 0.6.1+1 | ||
path | 1.6.4 | ||
sembast | 2.1.2 | ||
sky_engine | 0.0.99 | ||
synchronized | 2.1.1 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test | |||
pedantic | >=1.4.0 | ||
process_run | >=0.10.3 |