Hide routes from the API when they're not needed. (#3431)

The 'routes' table is a point of confusion with new developers. By
providing a 'home' argument that sets the '/' route, we can delay the
point at which we teach developers about 'routes' until the point where
they want to have a second route.
This commit is contained in:
Ian Hickson
2016-04-20 09:33:28 -07:00
parent f7360126b8
commit 1b9476c4d9
22 changed files with 553 additions and 517 deletions

View File

@@ -24,9 +24,7 @@ class ComplexLayoutAppState extends State<ComplexLayoutApp> {
return new MaterialApp(
theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(),
title: 'Advanced Layout',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new ComplexLayout(),
}
home: new ComplexLayout()
);
}

View File

@@ -465,8 +465,6 @@ class CardCollectionState extends State<CardCollection> {
void main() {
runApp(new MaterialApp(
title: 'Cards',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new CardCollection(),
}
home: new CardCollection()
));
}

View File

@@ -298,8 +298,6 @@ class DragAndDropAppState extends State<DragAndDropApp> {
void main() {
runApp(new MaterialApp(
title: 'Drag and Drop Flutter Demo',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new DragAndDropApp()
}
home: new DragAndDropApp()
));
}

View File

@@ -249,6 +249,6 @@ class _WindowManagerState extends State<WindowManager> {
void main() {
runApp(new MaterialApp(
title: 'Mozart',
routes: <String, WidgetBuilder>{ '/': (_) => new WindowManager() }
home: new WindowManager()
));
}

View File

@@ -201,8 +201,6 @@ void main() {
accentColor: Colors.redAccent[200]
),
title: 'Cards',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new OverlayGeometryApp()
}
home: new OverlayGeometryApp()
));
}

View File

@@ -145,8 +145,6 @@ void main() {
primarySwatch: Colors.blue,
accentColor: Colors.redAccent[200]
),
routes: <String, WidgetBuilder>{
'/': (BuildContext context) => new PageableListApp(),
}
home: new PageableListApp()
));
}

View File

@@ -9,25 +9,19 @@ import 'package:sky_services/sky/input_event.mojom.dart' as mojom;
GlobalKey _key = new GlobalKey();
void main() {
runApp(
new MaterialApp(
title: "Hardware Key Demo",
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Hardware Key Demo")
),
body: new Material(
child: new RawKeyboardDemo(
key: _key
)
)
);
}
}
runApp(new MaterialApp(
title: "Hardware Key Demo",
home: new Scaffold(
appBar: new AppBar(
title: new Text("Hardware Key Demo")
),
body: new Material(
child: new RawKeyboardDemo(
key: _key
)
)
)
);
));
}
class RawKeyboardDemo extends StatefulWidget {