1import 'package:isar/isar.dart';
2import 'package:path_provider/path_provider.dart';
15 Future<void>
initialize(List<CollectionSchema<dynamic>> schemas) async {
16 if (
_isar != null)
return;
18 final dir = await getApplicationDocumentsDirectory();
19 _isar = await Isar.open(
27 throw Exception(
'Isar not initialized. Call initialize() first.');
33 return isar.collection<T>();
36 Future<Id>
put<T>(T
object) async {
38 await
isar.writeTxn(() async {
44 Future<List<Id>>
putAll<T>(List<T> objects) async {
46 await
isar.writeTxn(() async {
52 Future<T?>
get<T>(Id
id) async {
62 await
isar.writeTxn(() async {
70 await
isar.writeTxn(() async {
81 await
isar.writeTxn(() async {
86 Stream<void>
watch<T>({
bool fireImmediately =
false}) {
87 return collection<T>().watchLazy(fireImmediately: fireImmediately);
Future< int > count() async
static IsarLocalDatabase _instance
Future< bool > delete(Id id) async
Future< List< Id > > putAll(List< T > objects) async
Future< List< T > > getAll() async
IsarCollection< T > collection()
static IsarLocalDatabase get instance
Stream< void > watch({bool fireImmediately=false})
Future< int > deleteAll(List< Id > ids) async
Future< Id > put(T object) async
Future< void > close() async
Future< void > clear() async
Future< void > initialize(List< CollectionSchema< dynamic > > schemas) async
Future< T?> get(Id id) async