@@ -3028,11 +3028,7 @@ class Navigator extends StatefulWidget {
30283028 return true ;
30293029 }());
30303030 result.add (
3031- navigator._routeNamed <dynamic >(
3032- Navigator .defaultRouteName,
3033- arguments: null ,
3034- allowNull: true ,
3035- ),
3031+ navigator._routeNamed (Navigator .defaultRouteName, arguments: null , allowNull: true ),
30363032 );
30373033 final List <String > routeParts = initialRouteName.split ('/' );
30383034 if (initialRouteName.isNotEmpty) {
@@ -3043,7 +3039,7 @@ class Navigator extends StatefulWidget {
30433039 debugRouteNames! .add (routeName);
30443040 return true ;
30453041 }());
3046- result.add (navigator._routeNamed < dynamic > (routeName, arguments: null , allowNull: true ));
3042+ result.add (navigator._routeNamed (routeName, arguments: null , allowNull: true ));
30473043 }
30483044 }
30493045 if (result.last == null ) {
@@ -3067,9 +3063,7 @@ class Navigator extends StatefulWidget {
30673063 } else if (initialRouteName != Navigator .defaultRouteName) {
30683064 // If initialRouteName wasn't '/', then we try to get it with allowNull:true, so that if that fails,
30693065 // we fall back to '/' (without allowNull:true, see below).
3070- result.add (
3071- navigator._routeNamed <dynamic >(initialRouteName, arguments: null , allowNull: true ),
3072- );
3066+ result.add (navigator._routeNamed (initialRouteName, arguments: null , allowNull: true ));
30733067 }
30743068 // Null route might be a result of gap in initialRouteName
30753069 //
@@ -3079,7 +3073,7 @@ class Navigator extends StatefulWidget {
30793073 // result = ['A', 'A/B/C'].
30803074 result.removeWhere ((Route <dynamic >? route) => route == null );
30813075 if (result.isEmpty) {
3082- result.add (navigator._routeNamed < dynamic > (Navigator .defaultRouteName, arguments: null ));
3076+ result.add (navigator._routeNamed (Navigator .defaultRouteName, arguments: null ));
30833077 }
30843078 return result.cast <Route <dynamic >>();
30853079 }
@@ -4685,7 +4679,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
46854679 return index < _history.length ? _history[index] : null ;
46864680 }
46874681
4688- Route <T ?>? _routeNamed < T > (String name, {required Object ? arguments, bool allowNull = false }) {
4682+ Route <Object ?>? _routeNamed (String name, {required Object ? arguments, bool allowNull = false }) {
46894683 assert (! _debugLocked);
46904684 if (allowNull && widget.onGenerateRoute == null ) {
46914685 return null ;
@@ -4704,7 +4698,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
47044698 return true ;
47054699 }());
47064700 final settings = RouteSettings (name: name, arguments: arguments);
4707- var route = widget.onGenerateRoute !(settings) as Route < T ?> ? ;
4701+ Route < Object ?> ? route = widget.onGenerateRoute !(settings);
47084702 if (route == null && ! allowNull) {
47094703 assert (() {
47104704 if (widget.onUnknownRoute == null ) {
@@ -4725,7 +4719,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
47254719 }
47264720 return true ;
47274721 }());
4728- route = widget.onUnknownRoute !(settings) as Route < T ?> ? ;
4722+ route = widget.onUnknownRoute !(settings);
47294723 assert (() {
47304724 if (route == null ) {
47314725 throw FlutterError .fromParts (< DiagnosticsNode > [
@@ -4773,7 +4767,8 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
47734767 @awaitNotRequired
47744768 @optionalTypeArgs
47754769 Future <T ?> pushNamed <T extends Object ?>(String routeName, {Object ? arguments}) {
4776- return push <T ?>(_routeNamed <T >(routeName, arguments: arguments)! );
4770+ final Route <Object ?> route = _routeNamed (routeName, arguments: arguments)! ;
4771+ return push <Object ?>(route).then ((Object ? result) => result as T ? );
47774772 }
47784773
47794774 /// Push a named route onto the navigator.
@@ -4843,10 +4838,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
48434838 TO ? result,
48444839 Object ? arguments,
48454840 }) {
4846- return pushReplacement <T ?, TO >(
4847- _routeNamed < T > (routeName, arguments: arguments)! ,
4841+ return pushReplacement <Object ?, Object ? >(
4842+ _routeNamed (routeName, arguments: arguments)! ,
48484843 result: result,
4849- );
4844+ ). then (( Object ? value) => value as T ? ) ;
48504845 }
48514846
48524847 /// Replace the current route of the navigator by pushing the route named
@@ -4987,7 +4982,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
49874982 RoutePredicate predicate, {
49884983 Object ? arguments,
49894984 }) {
4990- return pushAndRemoveUntil <T ?>(_routeNamed <T >(newRouteName, arguments: arguments)! , predicate);
4985+ return pushAndRemoveUntil <Object ?>(
4986+ _routeNamed (newRouteName, arguments: arguments)! ,
4987+ predicate,
4988+ ).then ((Object ? result) => result as T ? );
49914989 }
49924990
49934991 /// Push the route with the given name onto the navigator, and then remove all
@@ -6084,8 +6082,7 @@ class _NamedRestorationInformation extends _RestorationInformation {
60846082
60856083 @override
60866084 Route <dynamic > createRoute (NavigatorState navigator) {
6087- final Route <dynamic > route = navigator._routeNamed <dynamic >(name, arguments: arguments)! ;
6088- return route;
6085+ return navigator._routeNamed (name, arguments: arguments)! ;
60896086 }
60906087}
60916088
0 commit comments