build method

  1. @override
EditBuffer build({
  1. required String type,
  2. required String id,
  3. EntityEncoder<T>? toGraph,
})

Implementation

@override
EditBuffer build({
  required String type,
  required String id,
  EntityEncoder<T>? toGraph,
}) {
  final graph = ref.watch(entityGraphProvider);
  _graphSubscription = graph.changes.listen((change) {
    if ((change is GraphReset ||
            change is EntityChanged &&
                change.type == type &&
                change.id == id) &&
        !state.isDirty &&
        !state.isSaving) {
      state = EditBuffer(original: graph.readEntity(type, id) ?? const {});
    }
  });
  ref.onDispose(() => unawaited(_graphSubscription?.cancel()));
  return EditBuffer(original: graph.readEntity(type, id) ?? const {});
}