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

@@ -218,14 +218,9 @@ class _GestureDemoState extends State<GestureDemo> {
void main() {
runApp(new MaterialApp(
theme: new ThemeData.dark(),
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Gestures Demo')),
body: new GestureDemo()
);
}
}
home: new Scaffold(
appBar: new AppBar(title: new Text('Gestures Demo')),
body: new GestureDemo()
)
));
}

View File

@@ -100,15 +100,11 @@ final List<String> _kNames = _initNames();
void main() {
runApp(new MaterialApp(
title: 'Media Query Example',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Media Query Example')
),
body: new Material(child: new AdaptiveContainer(names: _kNames))
);
}
}
home: new Scaffold(
appBar: new AppBar(
title: new Text('Media Query Example')
),
body: new Material(child: new AdaptiveContainer(names: _kNames))
)
));
}

View File

@@ -153,16 +153,12 @@ class SectorAppState extends State<SectorApp> {
return new MaterialApp(
theme: new ThemeData.light(),
title: 'Sector Layout',
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Sector Layout in a Widget Tree')
),
body: buildBody()
);
}
}
home: new Scaffold(
appBar: new AppBar(
title: new Text('Sector Layout in a Widget Tree')
),
body: buildBody()
)
);
}
}

View File

@@ -122,17 +122,14 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
void main() {
runApp(new MaterialApp(
theme: new ThemeData.light(),
routes: <String, WidgetBuilder>{
'/': (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Hal and Dave')),
body: new Material(
color: Colors.grey[50],
child: new StyledTextDemo()
)
);
}
}
home: new Scaffold(
appBar: new AppBar(
title: new Text('Hal and Dave')
),
body: new Material(
color: Colors.grey[50],
child: new StyledTextDemo()
)
)
));
}