Commit 73ff4198 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Let MaterialApp override the initial route (#6216)

Fixes #6215
parent aed056c6
......@@ -52,6 +52,7 @@ class MaterialApp extends StatefulWidget {
this.theme,
this.home,
this.routes: const <String, WidgetBuilder>{},
this.initialRoute,
this.onGenerateRoute,
this.onLocaleChanged,
this.debugShowMaterialGrid: false,
......@@ -110,6 +111,11 @@ class MaterialApp extends StatefulWidget {
/// build the page instead.
final Map<String, WidgetBuilder> routes;
/// The name of the first route to show.
///
/// Defaults to [Window.defaultRouteName].
final String initialRoute;
/// The route generator callback used when the app is navigated to a
/// named route.
final RouteFactory onGenerateRoute;
......@@ -254,6 +260,7 @@ class _MaterialAppState extends State<MaterialApp> {
// blue[500] is the primary color of the default theme
color: config.color ?? theme?.primaryColor ?? Colors.blue[500],
navigatorObserver: _heroController,
initialRoute: config.initialRoute,
onGenerateRoute: _onGenerateRoute,
onLocaleChanged: config.onLocaleChanged,
showPerformanceOverlay: config.showPerformanceOverlay,
......
......@@ -43,6 +43,7 @@ class WidgetsApp extends StatefulWidget {
this.textStyle,
this.color,
this.navigatorObserver,
this.initialRoute,
this.onLocaleChanged,
this.showPerformanceOverlay: false,
this.showSemanticsDebugger: false,
......@@ -70,6 +71,11 @@ class WidgetsApp extends StatefulWidget {
/// named route.
final RouteFactory onGenerateRoute;
/// The name of the first route to show.
///
/// Defaults to [Window.defaultRouteName].
final String initialRoute;
/// Callback that is called when the operating system changes the
/// current locale.
final LocaleChangedCallback onLocaleChanged;
......@@ -176,7 +182,7 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
color: config.color,
child: new Navigator(
key: _navigator,
initialRoute: ui.window.defaultRouteName,
initialRoute: config.initialRoute ?? ui.window.defaultRouteName,
onGenerateRoute: config.onGenerateRoute,
observer: config.navigatorObserver
)
......
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