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:
@@ -301,11 +301,5 @@ class IsolateExampleState extends State<StatefulWidget> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
new MaterialApp(
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => new IsolateExampleWidget()
|
||||
}
|
||||
)
|
||||
);
|
||||
runApp(new MaterialApp(home: new IsolateExampleWidget()));
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -24,16 +24,14 @@ class GalleryAppState extends State<GalleryApp> {
|
||||
title: 'Flutter Material Gallery',
|
||||
theme: _useLightTheme ? _kGalleryLightTheme : _kGalleryDarkTheme,
|
||||
showPerformanceOverlay: _showPerformanceOverlay,
|
||||
routes: {
|
||||
'/': (BuildContext context) => new GalleryHome(
|
||||
useLightTheme: _useLightTheme,
|
||||
onThemeChanged: (bool value) { setState(() { _useLightTheme = value; }); },
|
||||
showPerformanceOverlay: _showPerformanceOverlay,
|
||||
onShowPerformanceOverlayChanged: (bool value) { setState(() { _showPerformanceOverlay = value; }); },
|
||||
timeDilation: timeDilation,
|
||||
onTimeDilationChanged: (double value) { setState(() { timeDilation = value; }); }
|
||||
)
|
||||
}
|
||||
home: new GalleryHome(
|
||||
useLightTheme: _useLightTheme,
|
||||
onThemeChanged: (bool value) { setState(() { _useLightTheme = value; }); },
|
||||
showPerformanceOverlay: _showPerformanceOverlay,
|
||||
onShowPerformanceOverlayChanged: (bool value) { setState(() { _showPerformanceOverlay = value; }); },
|
||||
timeDilation: timeDilation,
|
||||
onTimeDilationChanged: (double value) { setState(() { timeDilation = value; }); }
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user