localstore 0.5.0+1
localstore: ^0.5.0+1 copied to clipboard
A JSON file-based storage package provides a persistent repository for simple NoSQL documents.
Localstore #
A JSON file-based storage package provides a persistent repository for simple NoSQL documents.
Getting Started #
- Calling
WidgetsFlutterBinding.ensureInitialized();
in main() before callingrunApp()
:
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
- Import
import 'package:localstore/localstore.dart';
import 'package:flutter/material.dart';
import 'package:localstore/localstore.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
- Creates an instance using the default
Localstore
final db = Localstore.instance;
or using anywhere in your project.
- Creates new item
// gets new id
final id = db.collection('todos').doc();
// save the item
db.collection('todos').doc(id).set({
'title': 'Todo title',
'done': false
});
- Gets item by id
final data = await db.collection('todos').doc(id).get();
- Delete item by id
db.collection('todos').doc(id).delete();
- Using stream
final stream = db.collection('todos').stream;
Features and bugs #
Please file feature requests and bugs at the issue tracker.