of static method
Looks up and returns the scoped controller
if watch is true dependent widget will watch changes of this scope otherwise it would just read it
throws an error if it does not find it
Implementation
static RouterScope of(BuildContext context, {bool watch = false}) {
RouterScope? scope;
if (watch) {
scope = context.dependOnInheritedWidgetOfExactType<RouterScope>();
} else {
scope = context.findAncestorWidgetOfExactType<RouterScope>();
}
assert(() {
if (scope == null) {
throw FlutterError('RouterScope operation requested with a context that does not include a RouterScope.\n'
'The context used to retrieve the Router must be that of a widget that '
'is a descendant of a RouterScope widget.');
}
return true;
}());
return scope!;
}