Created
February 5, 2020 07:09
-
-
Save kitoko552/e11199ddbb031b3cc89a93ada8390ed0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NavigatorState of( | |
BuildContext context, { | |
bool rootNavigator = false, | |
bool nullOk = false, | |
}) { | |
final NavigatorState navigator = rootNavigator | |
? context.rootAncestorStateOfType(const TypeMatcher<NavigatorState>()) | |
: context.ancestorStateOfType(const TypeMatcher<NavigatorState>()); | |
assert(() { | |
if (navigator == null && !nullOk) { | |
throw FlutterError( | |
'Navigator operation requested with a context that does not include a Navigator.\n' | |
'The context used to push or pop routes from the Navigator must be that of a ' | |
'widget that is a descendant of a Navigator widget.' | |
); | |
} | |
return true; | |
}()); | |
return navigator; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment