of static method
Implementation
static GetRootState of(BuildContext context) {
// Handles the case where the input context is a navigator element.
GetRootState? root;
if (context is StatefulElement && context.state is GetRootState) {
root = context.state as GetRootState;
}
root = context.findRootAncestorStateOfType<GetRootState>() ?? root;
assert(() {
if (root == null) {
throw FlutterError(
'GetRoot operation requested with a context that does not include a GetRoot widget.\n'
'Ensure that the context used is a descendant of a GetRoot widget. This typically means '
'that the GetRoot widget is missing from your widget tree or the current context is not '
'properly linked to it. Please check your widget hierarchy and ensure that GetRoot is properly '
'set up in your app.',
);
}
return true;
}());
return root!;
}