globalRef<R> method
Returns a state provided by a GlobalRefProvider.
If no reference with the given name
and type R
is
found, an StateError is thrown. The search starts
at the nearest state provider of the compoent and
proceeds in direction to the root of the node
hierarchy.
Implementation
Ref<R> globalRef<R>(String name) {
ComponentContext? ctx = this;
while (ctx != null) {
final ref = ctx._refs[name];
if (ref != null && ref._global && ref._type.type() == R) {
return ref as Ref<R>;
}
ctx = ctx._parent;
}
return throw StateError('no global ref with name $name and type $R found!');
}