提交 8213fd87 编写于 作者: I Ian Hickson

Merge pull request #1971 from Hixie/better-messages-for-MaterialApp

Better asserts for MaterialApp and Navigator
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册