save method

  1. @override
Future<T> save(
  1. String key,
  2. T model, {
  3. bool notify = true,
})
override

Saves model of type T with key in local storage.

By default notifies this modification to the associated GraphNotifier.

Implementation

@override
Future<T> save(String key, T model, {bool notify = true}) async {
  final keyExisted = box!.containsKey(key);
  final save = box!.put(key, model);
  if (notify) {
    graph._notify(
      [key],
      keyExisted ? DataGraphEventType.updateNode : DataGraphEventType.addNode,
    );
  }
  await save;
  return model;
}