Commit 88314077 authored by Hixie's avatar Hixie

Better asserts for MaterialApp and Navigator

- runApp(new MaterialApp()) was crashing long after the constructor. Now
  it asserts in a more useful location.
- remove the default name for NamedRouteSettings. It was unused anyway.
parent 5516d12f
...@@ -36,9 +36,12 @@ class MaterialApp extends StatefulComponent { ...@@ -36,9 +36,12 @@ class MaterialApp extends StatefulComponent {
Key key, Key key,
this.title, this.title,
this.theme, this.theme,
this.routes, this.routes: const <String, RouteBuilder>{},
this.onGenerateRoute this.onGenerateRoute
}) : super(key: key); }) : super(key: key) {
assert(routes != null);
assert(routes.containsKey(Navigator.defaultRouteName) || onGenerateRoute != null);
}
final String title; final String title;
final ThemeData theme; final ThemeData theme;
......
...@@ -23,7 +23,7 @@ abstract class Route { ...@@ -23,7 +23,7 @@ abstract class Route {
} }
class NamedRouteSettings { class NamedRouteSettings {
const NamedRouteSettings({ this.name: '<anonymous>', this.mostValuableKeys }); const NamedRouteSettings({ this.name, this.mostValuableKeys });
final String name; final String name;
final Set<Key> mostValuableKeys; final Set<Key> mostValuableKeys;
...@@ -92,6 +92,7 @@ class NavigatorState extends State<Navigator> { ...@@ -92,6 +92,7 @@ class NavigatorState extends State<Navigator> {
} }
void pushNamed(String name, { Set<Key> mostValuableKeys }) { void pushNamed(String name, { Set<Key> mostValuableKeys }) {
assert(name != null);
NamedRouteSettings settings = new NamedRouteSettings( NamedRouteSettings settings = new NamedRouteSettings(
name: name, name: name,
mostValuableKeys: mostValuableKeys mostValuableKeys: mostValuableKeys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment