find<N extends NodeInterface> method

N find<N extends NodeInterface>(
  1. BuildContext context, {
  2. Key? key,
})

Busca N desde el scope más cercano hacia arriba

Implementation

N find<N extends NodeInterface>(BuildContext context, {Key? key}) {
  final node = registry.getOrNull<N>(key: key);
  if (node != null) return node;

  // Sube al siguiente scope
  final parent = _findParentScope(context);
  if (parent != null) return parent.find<N>(context, key: key);

  throw FlutterError(
    'Node of type $N ${key != null ? 'with key $key ' : ''}not found in any TrinityScope.\n'
    'Make sure to register it with a NodeProvider.',
  );
}