Make Navigator.canPop handle the no-navigator case

Scaffold calls this to see if it should show a back arrow when there's
no drawer. With this change, everything continues to work.

Fixes styled_text and probably others.
This commit is contained in:
Hixie 2015-12-16 14:34:24 -08:00
parent 1d16ebff05
commit a0d6572977

View File

@ -145,7 +145,7 @@ class Navigator extends StatefulComponent {
static bool canPop(BuildContext context) { static bool canPop(BuildContext context) {
NavigatorState navigator = context.ancestorStateOfType(NavigatorState); NavigatorState navigator = context.ancestorStateOfType(NavigatorState);
return navigator.canPop(); return navigator != null && navigator.canPop();
} }
static void popAndPushNamed(BuildContext context, String routeName, { Set<Key> mostValuableKeys }) { static void popAndPushNamed(BuildContext context, String routeName, { Set<Key> mostValuableKeys }) {