Replace some dynamic
to Object?
type (#80772)
This commit is contained in:
parent
07a6b8f071
commit
12a2e682b4
@ -789,7 +789,7 @@ class _AppBarState extends State<AppBar> {
|
||||
final ColorScheme colorScheme = theme.colorScheme;
|
||||
final AppBarTheme appBarTheme = AppBarTheme.of(context);
|
||||
final ScaffoldState? scaffold = Scaffold.maybeOf(context);
|
||||
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
|
||||
final ModalRoute<Object?>? parentRoute = ModalRoute.of(context);
|
||||
|
||||
final FlexibleSpaceBarSettings? settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
|
||||
final Set<MaterialState> states = <MaterialState>{
|
||||
@ -799,7 +799,7 @@ class _AppBarState extends State<AppBar> {
|
||||
final bool hasDrawer = scaffold?.hasDrawer ?? false;
|
||||
final bool hasEndDrawer = scaffold?.hasEndDrawer ?? false;
|
||||
final bool canPop = parentRoute?.canPop ?? false;
|
||||
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
|
||||
final bool useCloseButton = parentRoute is PageRoute<Object?> && parentRoute.fullscreenDialog;
|
||||
|
||||
final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight;
|
||||
final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? true;
|
||||
|
@ -363,7 +363,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
||||
|
||||
void _ensureHistoryEntry() {
|
||||
if (_historyEntry == null) {
|
||||
final ModalRoute<dynamic>? route = ModalRoute.of(context);
|
||||
final ModalRoute<Object?>? route = ModalRoute.of(context);
|
||||
if (route != null) {
|
||||
_historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved);
|
||||
route.addLocalHistoryEntry(_historyEntry!);
|
||||
|
@ -452,7 +452,7 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
|
||||
_accessibleNavigation = mediaQuery.accessibleNavigation;
|
||||
|
||||
if (_snackBars.isNotEmpty) {
|
||||
final ModalRoute<dynamic>? route = ModalRoute.of(context);
|
||||
final ModalRoute<Object?>? route = ModalRoute.of(context);
|
||||
if (route == null || route.isCurrent) {
|
||||
if (_snackBarController!.isCompleted && _snackBarTimer == null) {
|
||||
final SnackBar snackBar = _snackBars.first._widget;
|
||||
@ -2408,7 +2408,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
// Important if the app/user takes an action that could repeatedly show a
|
||||
// bottom sheet.
|
||||
final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[];
|
||||
PersistentBottomSheetController<dynamic>? _currentBottomSheet;
|
||||
PersistentBottomSheetController<Object?>? _currentBottomSheet;
|
||||
final GlobalKey _currentBottomSheetKey = GlobalKey();
|
||||
|
||||
void _maybeBuildPersistentBottomSheet() {
|
||||
@ -2981,7 +2981,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
// TODO(Piinks): Remove old SnackBar API after migrating ScaffoldMessenger
|
||||
_accessibleNavigation = mediaQuery.accessibleNavigation;
|
||||
if (_snackBars.isNotEmpty) {
|
||||
final ModalRoute<dynamic>? route = ModalRoute.of(context);
|
||||
final ModalRoute<Object?>? route = ModalRoute.of(context);
|
||||
if (route == null || route.isCurrent) {
|
||||
if (_snackBarController!.isCompleted && _snackBarTimer == null) {
|
||||
final SnackBar snackBar = _snackBars.first._widget;
|
||||
|
@ -487,8 +487,8 @@ class _HeroFlightManifest {
|
||||
final HeroFlightDirection type;
|
||||
final OverlayState overlay;
|
||||
final Size navigatorSize;
|
||||
final PageRoute<dynamic> fromRoute;
|
||||
final PageRoute<dynamic> toRoute;
|
||||
final PageRoute<Object?> fromRoute;
|
||||
final PageRoute<Object?> toRoute;
|
||||
final _HeroState fromHero;
|
||||
final _HeroState toHero;
|
||||
final CreateRectTween? createRectTween;
|
||||
@ -830,14 +830,14 @@ class HeroController extends NavigatorObserver {
|
||||
final Map<Object, _HeroFlight> _flights = <Object, _HeroFlight>{};
|
||||
|
||||
@override
|
||||
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
void didPush(Route<Object?> route, Route<Object?>? previousRoute) {
|
||||
assert(navigator != null);
|
||||
assert(route != null);
|
||||
_maybeStartHeroTransition(previousRoute, route, HeroFlightDirection.push, false);
|
||||
}
|
||||
|
||||
@override
|
||||
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
void didPop(Route<Object?> route, Route<Object?>? previousRoute) {
|
||||
assert(navigator != null);
|
||||
assert(route != null);
|
||||
// Don't trigger another flight when a pop is committed as a user gesture
|
||||
@ -847,7 +847,7 @@ class HeroController extends NavigatorObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
void didReplace({ Route<dynamic>? newRoute, Route<dynamic>? oldRoute }) {
|
||||
void didReplace({ Route<Object?>? newRoute, Route<Object?>? oldRoute }) {
|
||||
assert(navigator != null);
|
||||
if (newRoute?.isCurrent == true) {
|
||||
// Only run hero animations if the top-most route got replaced.
|
||||
@ -856,7 +856,7 @@ class HeroController extends NavigatorObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
void didStartUserGesture(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
void didStartUserGesture(Route<Object?> route, Route<Object?>? previousRoute) {
|
||||
assert(navigator != null);
|
||||
assert(route != null);
|
||||
_maybeStartHeroTransition(route, previousRoute, HeroFlightDirection.pop, true);
|
||||
@ -892,14 +892,14 @@ class HeroController extends NavigatorObserver {
|
||||
// If we're transitioning between different page routes, start a hero transition
|
||||
// after the toRoute has been laid out with its animation's value at 1.0.
|
||||
void _maybeStartHeroTransition(
|
||||
Route<dynamic>? fromRoute,
|
||||
Route<dynamic>? toRoute,
|
||||
Route<Object?>? fromRoute,
|
||||
Route<Object?>? toRoute,
|
||||
HeroFlightDirection flightType,
|
||||
bool isUserGestureTransition,
|
||||
) {
|
||||
if (toRoute != fromRoute && toRoute is PageRoute<dynamic> && fromRoute is PageRoute<dynamic>) {
|
||||
final PageRoute<dynamic> from = fromRoute;
|
||||
final PageRoute<dynamic> to = toRoute;
|
||||
if (toRoute != fromRoute && toRoute is PageRoute<Object?> && fromRoute is PageRoute<Object?>) {
|
||||
final PageRoute<Object?> from = fromRoute;
|
||||
final PageRoute<Object?> to = toRoute;
|
||||
final Animation<double> animation = (flightType == HeroFlightDirection.push) ? to.animation! : from.animation!;
|
||||
|
||||
// A user gesture may have already completed the pop, or we might be the initial route
|
||||
@ -940,8 +940,8 @@ class HeroController extends NavigatorObserver {
|
||||
// Find the matching pairs of heroes in from and to and either start or a new
|
||||
// hero flight, or divert an existing one.
|
||||
void _startHeroTransition(
|
||||
PageRoute<dynamic> from,
|
||||
PageRoute<dynamic> to,
|
||||
PageRoute<Object?> from,
|
||||
PageRoute<Object?> to,
|
||||
Animation<double> animation,
|
||||
HeroFlightDirection flightType,
|
||||
bool isUserGestureTransition,
|
||||
|
@ -38,12 +38,12 @@ import 'ticker_provider.dart';
|
||||
/// See also:
|
||||
///
|
||||
/// * [Navigator], which is where all the [Route]s end up.
|
||||
typedef RouteFactory = Route<dynamic>? Function(RouteSettings settings);
|
||||
typedef RouteFactory = Route<Object?>? Function(RouteSettings settings);
|
||||
|
||||
/// Creates a series of one or more routes.
|
||||
///
|
||||
/// Used by [Navigator.onGenerateInitialRoutes].
|
||||
typedef RouteListFactory = List<Route<dynamic>> Function(NavigatorState navigator, String initialRoute);
|
||||
typedef RouteListFactory = List<Route<Object?>> Function(NavigatorState navigator, String initialRoute);
|
||||
|
||||
/// Creates a [Route] that is to be added to a [Navigator].
|
||||
///
|
||||
@ -58,7 +58,7 @@ typedef RouteListFactory = List<Route<dynamic>> Function(NavigatorState navigato
|
||||
typedef RestorableRouteBuilder<T> = Route<T> Function(BuildContext context, Object? arguments);
|
||||
|
||||
/// Signature for the [Navigator.popUntil] predicate argument.
|
||||
typedef RoutePredicate = bool Function(Route<dynamic> route);
|
||||
typedef RoutePredicate = bool Function(Route<Object?> route);
|
||||
|
||||
/// Signature for a callback that verifies that it's OK to call [Navigator.pop].
|
||||
///
|
||||
@ -73,7 +73,7 @@ typedef WillPopCallback = Future<bool> Function();
|
||||
/// [Navigator.pages] so that it no longer includes the corresponding [Page].
|
||||
/// (Otherwise, the page will be interpreted as a new page to show when the
|
||||
/// [Navigator.pages] list is next updated.)
|
||||
typedef PopPageCallback = bool Function(Route<dynamic> route, dynamic result);
|
||||
typedef PopPageCallback = bool Function(Route<Object?> route, Object? result);
|
||||
|
||||
/// Indicates whether the current route should be popped.
|
||||
///
|
||||
@ -260,7 +260,7 @@ abstract class Route<T> {
|
||||
/// immediately after this method is called.
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void didReplace(Route<dynamic>? oldRoute) { }
|
||||
void didReplace(Route<Object?>? oldRoute) { }
|
||||
|
||||
/// Returns whether calling [Navigator.maybePop] when this [Route] is current
|
||||
/// ([isCurrent]) should do anything.
|
||||
@ -362,7 +362,7 @@ abstract class Route<T> {
|
||||
/// is no next route.
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void didPopNext(Route<dynamic> nextRoute) { }
|
||||
void didPopNext(Route<Object?> nextRoute) { }
|
||||
|
||||
/// This route's next route has changed to the given new route.
|
||||
///
|
||||
@ -375,7 +375,7 @@ abstract class Route<T> {
|
||||
/// if [isCurrent] is true).
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void didChangeNext(Route<dynamic>? nextRoute) { }
|
||||
void didChangeNext(Route<Object?>? nextRoute) { }
|
||||
|
||||
/// This route's previous route has changed to the given new route.
|
||||
///
|
||||
@ -388,7 +388,7 @@ abstract class Route<T> {
|
||||
/// (i.e. if [isFirst] is true).
|
||||
@protected
|
||||
@mustCallSuper
|
||||
void didChangePrevious(Route<dynamic>? previousRoute) { }
|
||||
void didChangePrevious(Route<Object?>? previousRoute) { }
|
||||
|
||||
/// Called whenever the internal state of the route has changed.
|
||||
///
|
||||
@ -588,7 +588,7 @@ abstract class Page<T> extends RouteSettings {
|
||||
///
|
||||
/// Two pages are consider updatable if they have same the [runtimeType] and
|
||||
/// [key].
|
||||
bool canUpdate(Page<dynamic> other) {
|
||||
bool canUpdate(Page<Object?> other) {
|
||||
return other.runtimeType == runtimeType &&
|
||||
other.key == key;
|
||||
}
|
||||
@ -613,13 +613,13 @@ class NavigatorObserver {
|
||||
///
|
||||
/// The route immediately below that one, and thus the previously active
|
||||
/// route, is `previousRoute`.
|
||||
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) { }
|
||||
void didPush(Route<Object?> route, Route<Object?>? previousRoute) { }
|
||||
|
||||
/// The [Navigator] popped `route`.
|
||||
///
|
||||
/// The route immediately below that one, and thus the newly active
|
||||
/// route, is `previousRoute`.
|
||||
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) { }
|
||||
void didPop(Route<Object?> route, Route<Object?>? previousRoute) { }
|
||||
|
||||
/// The [Navigator] removed `route`.
|
||||
///
|
||||
@ -630,16 +630,16 @@ class NavigatorObserver {
|
||||
/// bottommost route being removed, if any, is `previousRoute`, and this
|
||||
/// method will be called once for each removed route, from the topmost route
|
||||
/// to the bottommost route.
|
||||
void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) { }
|
||||
void didRemove(Route<Object?> route, Route<Object?>? previousRoute) { }
|
||||
|
||||
/// The [Navigator] replaced `oldRoute` with `newRoute`.
|
||||
void didReplace({ Route<dynamic>? newRoute, Route<dynamic>? oldRoute }) { }
|
||||
void didReplace({ Route<Object?>? newRoute, Route<Object?>? oldRoute }) { }
|
||||
|
||||
/// The [Navigator]'s routes are being moved by a user gesture.
|
||||
///
|
||||
/// For example, this is called when an iOS back gesture starts, and is used
|
||||
/// to disabled hero animations during such interactions.
|
||||
void didStartUserGesture(Route<dynamic> route, Route<dynamic>? previousRoute) { }
|
||||
void didStartUserGesture(Route<Object?> route, Route<Object?>? previousRoute) { }
|
||||
|
||||
/// User gesture is no longer controlling the [Navigator].
|
||||
///
|
||||
@ -694,7 +694,7 @@ class HeroControllerScope extends InheritedWidget {
|
||||
/// decide how its underlying [Route] should transition on or off screen.
|
||||
abstract class RouteTransitionRecord {
|
||||
/// Retrieves the wrapped [Route].
|
||||
Route<dynamic> get route;
|
||||
Route<Object?> get route;
|
||||
|
||||
/// Whether this route is waiting for the decision on how to enter the screen.
|
||||
///
|
||||
@ -729,14 +729,14 @@ abstract class RouteTransitionRecord {
|
||||
/// During [TransitionDelegate.resolve], this can be called on an exiting
|
||||
/// route to indicate that the route should be popped off the [Navigator] with
|
||||
/// an animated transition.
|
||||
void markForPop([dynamic result]);
|
||||
void markForPop([Object? result]);
|
||||
|
||||
/// Marks the [route] to be completed without transition.
|
||||
///
|
||||
/// During [TransitionDelegate.resolve], this can be called on an exiting
|
||||
/// route to indicate that the route should be completed with the provided
|
||||
/// result and removed from the [Navigator] without an animated transition.
|
||||
void markForComplete([dynamic result]);
|
||||
void markForComplete([Object? result]);
|
||||
|
||||
/// Marks the [route] to be removed without transition.
|
||||
///
|
||||
@ -1467,13 +1467,13 @@ class Navigator extends StatefulWidget {
|
||||
/// If the [pages] is not empty, the [onPopPage] must not be null.
|
||||
const Navigator({
|
||||
Key? key,
|
||||
this.pages = const <Page<dynamic>>[],
|
||||
this.pages = const <Page<Object?>>[],
|
||||
this.onPopPage,
|
||||
this.initialRoute,
|
||||
this.onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes,
|
||||
this.onGenerateRoute,
|
||||
this.onUnknownRoute,
|
||||
this.transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
|
||||
this.transitionDelegate = const DefaultTransitionDelegate<Object?>(),
|
||||
this.reportsRouteUpdateToEngine = false,
|
||||
this.observers = const <NavigatorObserver>[],
|
||||
this.restorationScopeId,
|
||||
@ -1512,7 +1512,7 @@ class Navigator extends StatefulWidget {
|
||||
/// If [initialRoute] is non-null when the widget is first created, then
|
||||
/// [onGenerateInitialRoutes] is used to generate routes that are above those
|
||||
/// corresponding to [pages] in the initial history.
|
||||
final List<Page<dynamic>> pages;
|
||||
final List<Page<Object?>> pages;
|
||||
|
||||
/// Called when [pop] is invoked but the current [Route] corresponds to a
|
||||
/// [Page] found in the [pages] list.
|
||||
@ -1533,7 +1533,7 @@ class Navigator extends StatefulWidget {
|
||||
/// during the [pages] updates.
|
||||
///
|
||||
/// Defaults to [DefaultTransitionDelegate] if not specified, cannot be null.
|
||||
final TransitionDelegate<dynamic> transitionDelegate;
|
||||
final TransitionDelegate<Object?> transitionDelegate;
|
||||
|
||||
/// The name of the first route to show.
|
||||
///
|
||||
@ -1994,7 +1994,7 @@ class Navigator extends StatefulWidget {
|
||||
/// [RoutePredicate] returned from [ModalRoute.withName].
|
||||
///
|
||||
/// To remove all the routes below the pushed route, use a [RoutePredicate]
|
||||
/// that always returns false (e.g. `(Route<dynamic> route) => false`).
|
||||
/// that always returns false (e.g. `(Route<Object?> route) => false`).
|
||||
///
|
||||
/// The removed routes are removed without being completed, so this method
|
||||
/// does not take a return value argument.
|
||||
@ -2297,7 +2297,7 @@ class Navigator extends StatefulWidget {
|
||||
/// [RoutePredicate] returned from [ModalRoute.withName].
|
||||
///
|
||||
/// To remove all the routes below the pushed route, use a [RoutePredicate]
|
||||
/// that always returns false (e.g. `(Route<dynamic> route) => false`).
|
||||
/// that always returns false (e.g. `(Route<Object?> route) => false`).
|
||||
///
|
||||
/// The removed routes are removed without being completed, so this method
|
||||
/// does not take a return value argument.
|
||||
@ -2429,7 +2429,7 @@ class Navigator extends StatefulWidget {
|
||||
/// * [restorableReplace], which adds a replacement route that can be
|
||||
/// restored during state restoration.
|
||||
@optionalTypeArgs
|
||||
static void replace<T extends Object?>(BuildContext context, { required Route<dynamic> oldRoute, required Route<T> newRoute }) {
|
||||
static void replace<T extends Object?>(BuildContext context, { required Route<Object?> oldRoute, required Route<T> newRoute }) {
|
||||
return Navigator.of(context).replace<T>(oldRoute: oldRoute, newRoute: newRoute);
|
||||
}
|
||||
|
||||
@ -2448,7 +2448,7 @@ class Navigator extends StatefulWidget {
|
||||
///
|
||||
/// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue}
|
||||
@optionalTypeArgs
|
||||
static String restorableReplace<T extends Object?>(BuildContext context, { required Route<dynamic> oldRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
static String restorableReplace<T extends Object?>(BuildContext context, { required Route<Object?> oldRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
return Navigator.of(context).restorableReplace<T>(oldRoute: oldRoute, newRouteBuilder: newRouteBuilder, arguments: arguments);
|
||||
}
|
||||
|
||||
@ -2484,7 +2484,7 @@ class Navigator extends StatefulWidget {
|
||||
/// * [restorableReplaceRouteBelow], which adds a replacement route that can
|
||||
/// be restored during state restoration.
|
||||
@optionalTypeArgs
|
||||
static void replaceRouteBelow<T extends Object?>(BuildContext context, { required Route<dynamic> anchorRoute, required Route<T> newRoute }) {
|
||||
static void replaceRouteBelow<T extends Object?>(BuildContext context, { required Route<Object?> anchorRoute, required Route<T> newRoute }) {
|
||||
return Navigator.of(context).replaceRouteBelow<T>(anchorRoute: anchorRoute, newRoute: newRoute);
|
||||
}
|
||||
|
||||
@ -2504,7 +2504,7 @@ class Navigator extends StatefulWidget {
|
||||
///
|
||||
/// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue}
|
||||
@optionalTypeArgs
|
||||
static String restorableReplaceRouteBelow<T extends Object?>(BuildContext context, { required Route<dynamic> anchorRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
static String restorableReplaceRouteBelow<T extends Object?>(BuildContext context, { required Route<Object?> anchorRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
return Navigator.of(context).restorableReplaceRouteBelow<T>(anchorRoute: anchorRoute, newRouteBuilder: newRouteBuilder, arguments: arguments);
|
||||
}
|
||||
|
||||
@ -2548,7 +2548,7 @@ class Navigator extends StatefulWidget {
|
||||
/// Android it's called by the binding for the system's back button.
|
||||
///
|
||||
/// The `T` type argument is the type of the return value of the current
|
||||
/// route. (Typically this isn't known; consider specifying `dynamic` or
|
||||
/// route. (Typically this isn't known; consider specifying `Object?` or
|
||||
/// `Null`.)
|
||||
/// {@endtemplate}
|
||||
///
|
||||
@ -2665,7 +2665,7 @@ class Navigator extends StatefulWidget {
|
||||
///
|
||||
/// This method is used, for example, to instantly dismiss dropdown menus that
|
||||
/// are up when the screen's orientation changes.
|
||||
static void removeRoute(BuildContext context, Route<dynamic> route) {
|
||||
static void removeRoute(BuildContext context, Route<Object?> route) {
|
||||
return Navigator.of(context).removeRoute(route);
|
||||
}
|
||||
|
||||
@ -2690,7 +2690,7 @@ class Navigator extends StatefulWidget {
|
||||
///
|
||||
/// Ongoing gestures within the current route are canceled.
|
||||
/// {@endtemplate}
|
||||
static void removeRouteBelow(BuildContext context, Route<dynamic> anchorRoute) {
|
||||
static void removeRouteBelow(BuildContext context, Route<Object?> anchorRoute) {
|
||||
return Navigator.of(context).removeRouteBelow(anchorRoute);
|
||||
}
|
||||
|
||||
@ -2791,8 +2791,8 @@ class Navigator extends StatefulWidget {
|
||||
/// then the [Navigator] would push the following routes on startup: `/`,
|
||||
/// `/stocks`, `/stocks/HOOLI`. This enables deep linking while allowing the
|
||||
/// application to maintain a predictable route history.
|
||||
static List<Route<dynamic>> defaultGenerateInitialRoutes(NavigatorState navigator, String initialRouteName) {
|
||||
final List<Route<dynamic>?> result = <Route<dynamic>?>[];
|
||||
static List<Route<Object?>> defaultGenerateInitialRoutes(NavigatorState navigator, String initialRouteName) {
|
||||
final List<Route<Object?>?> result = <Route<Object?>?>[];
|
||||
if (initialRouteName.startsWith('/') && initialRouteName.length > 1) {
|
||||
initialRouteName = initialRouteName.substring(1); // strip leading '/'
|
||||
assert(Navigator.defaultRouteName == '/');
|
||||
@ -2801,7 +2801,7 @@ class Navigator extends StatefulWidget {
|
||||
debugRouteNames = <String>[ Navigator.defaultRouteName ];
|
||||
return true;
|
||||
}());
|
||||
result.add(navigator._routeNamed<dynamic>(Navigator.defaultRouteName, arguments: null, allowNull: true));
|
||||
result.add(navigator._routeNamed<Object?>(Navigator.defaultRouteName, arguments: null, allowNull: true));
|
||||
final List<String> routeParts = initialRouteName.split('/');
|
||||
if (initialRouteName.isNotEmpty) {
|
||||
String routeName = '';
|
||||
@ -2811,7 +2811,7 @@ class Navigator extends StatefulWidget {
|
||||
debugRouteNames!.add(routeName);
|
||||
return true;
|
||||
}());
|
||||
result.add(navigator._routeNamed<dynamic>(routeName, arguments: null, allowNull: true));
|
||||
result.add(navigator._routeNamed<Object?>(routeName, arguments: null, allowNull: true));
|
||||
}
|
||||
}
|
||||
if (result.last == null) {
|
||||
@ -2832,7 +2832,7 @@ class Navigator extends StatefulWidget {
|
||||
} else if (initialRouteName != Navigator.defaultRouteName) {
|
||||
// If initialRouteName wasn't '/', then we try to get it with allowNull:true, so that if that fails,
|
||||
// we fall back to '/' (without allowNull:true, see below).
|
||||
result.add(navigator._routeNamed<dynamic>(initialRouteName, arguments: null, allowNull: true));
|
||||
result.add(navigator._routeNamed<Object?>(initialRouteName, arguments: null, allowNull: true));
|
||||
}
|
||||
// Null route might be a result of gap in initialRouteName
|
||||
//
|
||||
@ -2840,10 +2840,10 @@ class Navigator extends StatefulWidget {
|
||||
// This should result in result = ['A', null,'A/B/C'] where 'A/B' produces
|
||||
// the null. In this case, we want to filter out the null and return
|
||||
// result = ['A', 'A/B/C'].
|
||||
result.removeWhere((Route<dynamic>? route) => route == null);
|
||||
result.removeWhere((Route<Object?>? route) => route == null);
|
||||
if (result.isEmpty)
|
||||
result.add(navigator._routeNamed<dynamic>(Navigator.defaultRouteName, arguments: null));
|
||||
return result.cast<Route<dynamic>>();
|
||||
result.add(navigator._routeNamed<Object?>(Navigator.defaultRouteName, arguments: null));
|
||||
return result.cast<Route<Object?>>();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -2946,15 +2946,15 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
currentState = initialState;
|
||||
|
||||
@override
|
||||
final Route<dynamic> route;
|
||||
final Route<Object?> route;
|
||||
final _RestorationInformation? restorationInformation;
|
||||
|
||||
static Route<dynamic> notAnnounced = _NotAnnounced();
|
||||
static Route<Object?> notAnnounced = _NotAnnounced();
|
||||
|
||||
_RouteLifecycle currentState;
|
||||
Route<dynamic>? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious
|
||||
Route<dynamic> lastAnnouncedPoppedNextRoute = notAnnounced; // last argument to Route.didPopNext
|
||||
Route<dynamic>? lastAnnouncedNextRoute = notAnnounced; // last argument to Route.didChangeNext
|
||||
Route<Object?>? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious
|
||||
Route<Object?> lastAnnouncedPoppedNextRoute = notAnnounced; // last argument to Route.didPopNext
|
||||
Route<Object?>? lastAnnouncedNextRoute = notAnnounced; // last argument to Route.didChangeNext
|
||||
|
||||
/// Restoration ID to be used for the encapsulating route when restoration is
|
||||
/// enabled for it or null if restoration cannot be enabled for it.
|
||||
@ -2973,16 +2973,16 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
|
||||
bool get hasPage => route.settings is Page;
|
||||
|
||||
bool canUpdateFrom(Page<dynamic> page) {
|
||||
bool canUpdateFrom(Page<Object?> page) {
|
||||
if (currentState.index > _RouteLifecycle.idle.index)
|
||||
return false;
|
||||
if (!hasPage)
|
||||
return false;
|
||||
final Page<dynamic> routePage = route.settings as Page<dynamic>;
|
||||
final Page<Object?> routePage = route.settings as Page<Object?>;
|
||||
return page.canUpdate(routePage);
|
||||
}
|
||||
|
||||
void handleAdd({ required NavigatorState navigator, required Route<dynamic>? previousPresent }) {
|
||||
void handleAdd({ required NavigatorState navigator, required Route<Object?>? previousPresent }) {
|
||||
assert(currentState == _RouteLifecycle.add);
|
||||
assert(navigator != null);
|
||||
assert(navigator._debugLocked);
|
||||
@ -2996,7 +2996,7 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
);
|
||||
}
|
||||
|
||||
void handlePush({ required NavigatorState navigator, required bool isNewFirst, required Route<dynamic>? previous, required Route<dynamic>? previousPresent }) {
|
||||
void handlePush({ required NavigatorState navigator, required bool isNewFirst, required Route<Object?>? previous, required Route<Object?>? previousPresent }) {
|
||||
assert(currentState == _RouteLifecycle.push || currentState == _RouteLifecycle.pushReplace || currentState == _RouteLifecycle.replace);
|
||||
assert(navigator != null);
|
||||
assert(navigator._debugLocked);
|
||||
@ -3042,12 +3042,12 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
}
|
||||
}
|
||||
|
||||
void handleDidPopNext(Route<dynamic> poppedRoute) {
|
||||
void handleDidPopNext(Route<Object?> poppedRoute) {
|
||||
route.didPopNext(poppedRoute);
|
||||
lastAnnouncedPoppedNextRoute = poppedRoute;
|
||||
}
|
||||
|
||||
void handlePop({ required NavigatorState navigator, required Route<dynamic>? previousPresent }) {
|
||||
void handlePop({ required NavigatorState navigator, required Route<Object?>? previousPresent }) {
|
||||
assert(navigator != null);
|
||||
assert(navigator._debugLocked);
|
||||
assert(route._navigator == navigator);
|
||||
@ -3057,7 +3057,7 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
);
|
||||
}
|
||||
|
||||
void handleRemoval({ required NavigatorState navigator, required Route<dynamic>? previousPresent }) {
|
||||
void handleRemoval({ required NavigatorState navigator, required Route<Object?>? previousPresent }) {
|
||||
assert(navigator != null);
|
||||
assert(navigator._debugLocked);
|
||||
assert(route._navigator == navigator);
|
||||
@ -3181,7 +3181,7 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
currentState.index >= _RouteLifecycle.push.index;
|
||||
}
|
||||
|
||||
bool shouldAnnounceChangeToNext(Route<dynamic>? nextRoute) {
|
||||
bool shouldAnnounceChangeToNext(Route<Object?>? nextRoute) {
|
||||
assert(nextRoute != lastAnnouncedNextRoute);
|
||||
// Do not announce if `next` changes from a just popped route to null. We
|
||||
// already announced this change by calling didPopNext.
|
||||
@ -3196,7 +3196,7 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
static bool suitableForTransitionAnimationPredicate(_RouteEntry entry) => entry.suitableForTransitionAnimation;
|
||||
static bool willBePresentPredicate(_RouteEntry entry) => entry.willBePresent;
|
||||
|
||||
static _RouteEntryPredicate isRoutePredicate(Route<dynamic> route) {
|
||||
static _RouteEntryPredicate isRoutePredicate(Route<Object?> route) {
|
||||
return (_RouteEntry entry) => entry.route == route;
|
||||
}
|
||||
|
||||
@ -3230,25 +3230,25 @@ class _RouteEntry extends RouteTransitionRecord {
|
||||
}
|
||||
|
||||
@override
|
||||
void markForPop([dynamic result]) {
|
||||
void markForPop([Object? result]) {
|
||||
assert(
|
||||
!isWaitingForEnteringDecision && isWaitingForExitingDecision && isPresent,
|
||||
'This route cannot be marked for pop. Either a decision has already been '
|
||||
'made or it does not require an explicit decision on how to transition out.',
|
||||
);
|
||||
pop<dynamic>(result);
|
||||
pop<Object?>(result);
|
||||
_isWaitingForExitingDecision = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void markForComplete([dynamic result]) {
|
||||
void markForComplete([Object? result]) {
|
||||
assert(
|
||||
!isWaitingForEnteringDecision && isWaitingForExitingDecision && isPresent,
|
||||
'This route cannot be marked for complete. Either a decision has already '
|
||||
'been made or it does not require an explicit decision on how to transition '
|
||||
'out.',
|
||||
);
|
||||
complete<dynamic>(result);
|
||||
complete<Object?>(result);
|
||||
_isWaitingForExitingDecision = false;
|
||||
}
|
||||
|
||||
@ -3276,16 +3276,16 @@ abstract class _NavigatorObservation {
|
||||
this.primaryRoute,
|
||||
this.secondaryRoute,
|
||||
);
|
||||
final Route<dynamic> primaryRoute;
|
||||
final Route<dynamic>? secondaryRoute;
|
||||
final Route<Object?> primaryRoute;
|
||||
final Route<Object?>? secondaryRoute;
|
||||
|
||||
void notify(NavigatorObserver observer);
|
||||
}
|
||||
|
||||
class _NavigatorPushObservation extends _NavigatorObservation {
|
||||
_NavigatorPushObservation(
|
||||
Route<dynamic> primaryRoute,
|
||||
Route<dynamic>? secondaryRoute,
|
||||
Route<Object?> primaryRoute,
|
||||
Route<Object?>? secondaryRoute,
|
||||
) : super(primaryRoute, secondaryRoute);
|
||||
|
||||
@override
|
||||
@ -3296,8 +3296,8 @@ class _NavigatorPushObservation extends _NavigatorObservation {
|
||||
|
||||
class _NavigatorPopObservation extends _NavigatorObservation {
|
||||
_NavigatorPopObservation(
|
||||
Route<dynamic> primaryRoute,
|
||||
Route<dynamic>? secondaryRoute,
|
||||
Route<Object?> primaryRoute,
|
||||
Route<Object?>? secondaryRoute,
|
||||
) : super(primaryRoute, secondaryRoute);
|
||||
|
||||
@override
|
||||
@ -3308,8 +3308,8 @@ class _NavigatorPopObservation extends _NavigatorObservation {
|
||||
|
||||
class _NavigatorRemoveObservation extends _NavigatorObservation {
|
||||
_NavigatorRemoveObservation(
|
||||
Route<dynamic> primaryRoute,
|
||||
Route<dynamic>? secondaryRoute,
|
||||
Route<Object?> primaryRoute,
|
||||
Route<Object?>? secondaryRoute,
|
||||
) : super(primaryRoute, secondaryRoute);
|
||||
|
||||
@override
|
||||
@ -3320,8 +3320,8 @@ class _NavigatorRemoveObservation extends _NavigatorObservation {
|
||||
|
||||
class _NavigatorReplaceObservation extends _NavigatorObservation {
|
||||
_NavigatorReplaceObservation(
|
||||
Route<dynamic> primaryRoute,
|
||||
Route<dynamic>? secondaryRoute,
|
||||
Route<Object?> primaryRoute,
|
||||
Route<Object?>? secondaryRoute,
|
||||
) : super(primaryRoute, secondaryRoute);
|
||||
|
||||
@override
|
||||
@ -3353,7 +3353,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
void initState() {
|
||||
super.initState();
|
||||
assert((){
|
||||
if (widget.pages != const <Page<dynamic>>[]) {
|
||||
if (widget.pages != const <Page<Object?>>[]) {
|
||||
// This navigator uses page API.
|
||||
if (widget.pages.isEmpty) {
|
||||
FlutterError.reportError(
|
||||
@ -3414,7 +3414,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
|
||||
// Populate the new history from restoration data.
|
||||
_history.addAll(_serializableHistory.restoreEntriesForPage(null, this));
|
||||
for (final Page<dynamic> page in widget.pages) {
|
||||
for (final Page<Object?> page in widget.pages) {
|
||||
final _RouteEntry entry = _RouteEntry(
|
||||
page.createRoute(context),
|
||||
initialState: _RouteLifecycle.add,
|
||||
@ -3439,7 +3439,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
widget.onGenerateInitialRoutes(
|
||||
this,
|
||||
widget.initialRoute ?? Navigator.defaultRouteName,
|
||||
).map((Route<dynamic> route) => _RouteEntry(
|
||||
).map((Route<Object?> route) => _RouteEntry(
|
||||
route,
|
||||
initialState: _RouteLifecycle.add,
|
||||
restorationInformation: route.settings.name != null
|
||||
@ -3550,7 +3550,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
void didUpdateWidget(Navigator oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
assert((){
|
||||
if (widget.pages != const <Page<dynamic>>[]) {
|
||||
if (widget.pages != const <Page<Object?>>[]) {
|
||||
// This navigator uses page API.
|
||||
if (widget.pages.isEmpty) {
|
||||
FlutterError.reportError(
|
||||
@ -3613,7 +3613,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
void _debugCheckDuplicatedPageKeys() {
|
||||
assert((){
|
||||
final Set<Key> keyReservation = <Key>{};
|
||||
for (final Page<dynamic> page in widget.pages) {
|
||||
for (final Page<Object?> page in widget.pages) {
|
||||
final LocalKey? key = page.key;
|
||||
if (key != null) {
|
||||
assert(!keyReservation.contains(key));
|
||||
@ -3726,7 +3726,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
}
|
||||
if (newPagesBottom > newPagesTop)
|
||||
break;
|
||||
final Page<dynamic> newPage = widget.pages[newPagesBottom];
|
||||
final Page<Object?> newPage = widget.pages[newPagesBottom];
|
||||
if (!oldEntry.canUpdateFrom(newPage))
|
||||
break;
|
||||
previousOldPageRouteEntry = oldEntry;
|
||||
@ -3748,7 +3748,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
oldEntriesTop -= 1;
|
||||
continue;
|
||||
}
|
||||
final Page<dynamic> newPage = widget.pages[newPagesTop];
|
||||
final Page<Object?> newPage = widget.pages[newPagesTop];
|
||||
if (!oldEntry.canUpdateFrom(newPage))
|
||||
break;
|
||||
// We found the page for all the consecutive pageless routes below. Those
|
||||
@ -3777,7 +3777,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
|
||||
assert(oldEntry.hasPage);
|
||||
|
||||
final Page<dynamic> page = oldEntry.route.settings as Page<dynamic>;
|
||||
final Page<Object?> page = oldEntry.route.settings as Page<Object?>;
|
||||
if (page.key == null)
|
||||
continue;
|
||||
|
||||
@ -3787,7 +3787,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
|
||||
// Updates the middle of the list.
|
||||
while (newPagesBottom <= newPagesTop) {
|
||||
final Page<dynamic> nextPage = widget.pages[newPagesBottom];
|
||||
final Page<Object?> nextPage = widget.pages[newPagesBottom];
|
||||
newPagesBottom += 1;
|
||||
if (
|
||||
nextPage.key == null ||
|
||||
@ -3836,7 +3836,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
continue;
|
||||
}
|
||||
|
||||
final Page<dynamic> potentialPageToRemove = potentialEntryToRemove.route.settings as Page<dynamic>;
|
||||
final Page<Object?> potentialPageToRemove = potentialEntryToRemove.route.settings as Page<Object?>;
|
||||
// Marks for transition delegate to remove if this old page does not have
|
||||
// a key or was not taken during updating the middle of new page.
|
||||
if (
|
||||
@ -3882,7 +3882,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
continue;
|
||||
}
|
||||
previousOldPageRouteEntry = oldEntry;
|
||||
final Page<dynamic> newPage = widget.pages[newPagesBottom];
|
||||
final Page<Object?> newPage = widget.pages[newPagesBottom];
|
||||
assert(oldEntry.canUpdateFrom(newPage));
|
||||
oldEntry.route._updateSettings(newPage);
|
||||
newHistory.add(oldEntry);
|
||||
@ -3928,7 +3928,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
_RouteEntry? entry = _history[index];
|
||||
_RouteEntry? previous = index > 0 ? _history[index - 1] : null;
|
||||
bool canRemoveOrAdd = false; // Whether there is a fully opaque route on top to silently remove or add route underneath.
|
||||
Route<dynamic>? poppedRoute; // The route that should trigger didPopNext on the top active route.
|
||||
Route<Object?>? poppedRoute; // The route that should trigger didPopNext on the top active route.
|
||||
bool seenTopActiveRoute = false; // Whether we've seen the route that would get didPopNext.
|
||||
final List<_RouteEntry> toBeDisposed = <_RouteEntry>[];
|
||||
while (index >= 0) {
|
||||
@ -4481,7 +4481,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
return route.popped;
|
||||
}
|
||||
|
||||
bool _debugCheckIsPagelessRoute(Route<dynamic> route) {
|
||||
bool _debugCheckIsPagelessRoute(Route<Object?> route) {
|
||||
assert((){
|
||||
if (route.settings is Page) {
|
||||
FlutterError.reportError(
|
||||
@ -4578,19 +4578,19 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
_afterNavigation(entry.route);
|
||||
}
|
||||
|
||||
void _afterNavigation(Route<dynamic>? route) {
|
||||
void _afterNavigation(Route<Object?>? route) {
|
||||
if (!kReleaseMode) {
|
||||
// Among other uses, performance tools use this event to ensure that perf
|
||||
// stats reflect the time interval since the last navigation event
|
||||
// occurred, ensuring that stats only reflect the current page.
|
||||
|
||||
Map<String, dynamic>? routeJsonable;
|
||||
Map<String, Object?>? routeJsonable;
|
||||
if (route != null) {
|
||||
routeJsonable = <String, dynamic>{};
|
||||
routeJsonable = <String, Object?>{};
|
||||
|
||||
final String description;
|
||||
if (route is TransitionRoute<dynamic>) {
|
||||
final TransitionRoute<dynamic> transitionRoute = route;
|
||||
if (route is TransitionRoute<Object?>) {
|
||||
final TransitionRoute<Object?> transitionRoute = route;
|
||||
description = transitionRoute.debugLabel;
|
||||
} else {
|
||||
description = '$route';
|
||||
@ -4598,7 +4598,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
routeJsonable['description'] = description;
|
||||
|
||||
final RouteSettings settings = route.settings;
|
||||
final Map<String, dynamic> settingsJsonable = <String, dynamic> {
|
||||
final Map<String, Object?> settingsJsonable = <String, Object?> {
|
||||
'name': settings.name,
|
||||
};
|
||||
if (settings.arguments != null) {
|
||||
@ -4610,7 +4610,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
routeJsonable['settings'] = settingsJsonable;
|
||||
}
|
||||
|
||||
developer.postEvent('Flutter.Navigation', <String, dynamic>{
|
||||
developer.postEvent('Flutter.Navigation', <String, Object?>{
|
||||
'route': routeJsonable,
|
||||
});
|
||||
}
|
||||
@ -4852,7 +4852,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
/// * [restorableReplace], which adds a replacement route that can be
|
||||
/// restored during state restoration.
|
||||
@optionalTypeArgs
|
||||
void replace<T extends Object?>({ required Route<dynamic> oldRoute, required Route<T> newRoute }) {
|
||||
void replace<T extends Object?>({ required Route<Object?> oldRoute, required Route<T> newRoute }) {
|
||||
assert(!_debugLocked);
|
||||
assert(oldRoute != null);
|
||||
assert(oldRoute._navigator == this);
|
||||
@ -4870,7 +4870,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
///
|
||||
/// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue}
|
||||
@optionalTypeArgs
|
||||
String restorableReplace<T extends Object?>({ required Route<dynamic> oldRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
String restorableReplace<T extends Object?>({ required Route<Object?> oldRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
assert(oldRoute != null);
|
||||
assert(oldRoute._navigator == this);
|
||||
assert(newRouteBuilder != null);
|
||||
@ -4886,7 +4886,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
return entry.restorationId!;
|
||||
}
|
||||
|
||||
void _replaceEntry(_RouteEntry entry, Route<dynamic> oldRoute) {
|
||||
void _replaceEntry(_RouteEntry entry, Route<Object?> oldRoute) {
|
||||
assert(!_debugLocked);
|
||||
if (oldRoute == entry.route)
|
||||
return;
|
||||
@ -4923,7 +4923,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
/// * [restorableReplaceRouteBelow], which adds a replacement route that can
|
||||
/// be restored during state restoration.
|
||||
@optionalTypeArgs
|
||||
void replaceRouteBelow<T extends Object?>({ required Route<dynamic> anchorRoute, required Route<T> newRoute }) {
|
||||
void replaceRouteBelow<T extends Object?>({ required Route<Object?> anchorRoute, required Route<T> newRoute }) {
|
||||
assert(newRoute != null);
|
||||
assert(newRoute._navigator == null);
|
||||
assert(anchorRoute != null);
|
||||
@ -4942,7 +4942,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
///
|
||||
/// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue}
|
||||
@optionalTypeArgs
|
||||
String restorableReplaceRouteBelow<T extends Object?>({ required Route<dynamic> anchorRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
String restorableReplaceRouteBelow<T extends Object?>({ required Route<Object?> anchorRoute, required RestorableRouteBuilder<T> newRouteBuilder, Object? arguments }) {
|
||||
assert(anchorRoute != null);
|
||||
assert(anchorRoute._navigator == this);
|
||||
assert(newRouteBuilder != null);
|
||||
@ -4958,7 +4958,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
return entry.restorationId!;
|
||||
}
|
||||
|
||||
void _replaceEntryBelow(_RouteEntry entry, Route<dynamic> anchorRoute) {
|
||||
void _replaceEntryBelow(_RouteEntry entry, Route<Object?> anchorRoute) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
final int anchorIndex = _history.indexWhere(_RouteEntry.isRoutePredicate(anchorRoute));
|
||||
@ -5122,7 +5122,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
/// Immediately remove `route` from the navigator, and [Route.dispose] it.
|
||||
///
|
||||
/// {@macro flutter.widgets.navigator.removeRoute}
|
||||
void removeRoute(Route<dynamic> route) {
|
||||
void removeRoute(Route<Object?> route) {
|
||||
assert(route != null);
|
||||
assert(!_debugLocked);
|
||||
assert(() {
|
||||
@ -5152,7 +5152,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
/// route to be removed is the one below the given `anchorRoute`.
|
||||
///
|
||||
/// {@macro flutter.widgets.navigator.removeRouteBelow}
|
||||
void removeRouteBelow(Route<dynamic> anchorRoute) {
|
||||
void removeRouteBelow(Route<Object?> anchorRoute) {
|
||||
assert(!_debugLocked);
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
@ -5189,7 +5189,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
/// The given `route` must have already received a call to [Route.didPop].
|
||||
/// This function may be called directly from [Route.didPop] if [Route.didPop]
|
||||
/// will return true.
|
||||
void finalizeRoute(Route<dynamic> route) {
|
||||
void finalizeRoute(Route<Object?> route) {
|
||||
// FinalizeRoute may have been called while we were already locked as a
|
||||
// responds to route.didPop(). Make sure to leave in the state we were in
|
||||
// before the call.
|
||||
@ -5250,8 +5250,8 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
|
||||
_RouteEntry.willBePresentPredicate,
|
||||
);
|
||||
assert(routeIndex != null);
|
||||
final Route<dynamic> route = _history[routeIndex].route;
|
||||
Route<dynamic>? previousRoute;
|
||||
final Route<Object?> route = _history[routeIndex].route;
|
||||
Route<Object?>? previousRoute;
|
||||
if (!route.willHandlePopInternally && routeIndex > 0) {
|
||||
previousRoute = _getRouteBefore(
|
||||
routeIndex - 1,
|
||||
@ -5382,7 +5382,7 @@ abstract class _RestorationInformation {
|
||||
}
|
||||
|
||||
@protected
|
||||
Route<dynamic> createRoute(NavigatorState navigator);
|
||||
Route<Object?> createRoute(NavigatorState navigator);
|
||||
|
||||
_RouteEntry toRouteEntry(NavigatorState navigator, {_RouteLifecycle initialState = _RouteLifecycle.add}) {
|
||||
assert(navigator != null);
|
||||
@ -5429,8 +5429,8 @@ class _NamedRestorationInformation extends _RestorationInformation {
|
||||
final Object? arguments;
|
||||
|
||||
@override
|
||||
Route<dynamic> createRoute(NavigatorState navigator) {
|
||||
final Route<dynamic> route = navigator._routeNamed<dynamic>(name, arguments: arguments, allowNull: false)!;
|
||||
Route<Object?> createRoute(NavigatorState navigator) {
|
||||
final Route<Object?> route = navigator._routeNamed<Object?>(name, arguments: arguments, allowNull: false)!;
|
||||
assert(route != null);
|
||||
return route;
|
||||
}
|
||||
@ -5476,8 +5476,8 @@ class _AnonymousRestorationInformation extends _RestorationInformation {
|
||||
final Object? arguments;
|
||||
|
||||
@override
|
||||
Route<dynamic> createRoute(NavigatorState navigator) {
|
||||
final Route<dynamic> result = routeBuilder(navigator.context, arguments);
|
||||
Route<Object?> createRoute(NavigatorState navigator) {
|
||||
final Route<Object?> result = routeBuilder(navigator.context, arguments);
|
||||
assert(result != null);
|
||||
return result;
|
||||
}
|
||||
@ -5621,10 +5621,10 @@ class _HistoryProperty extends RestorableProperty<Map<String?, List<Object>>?> {
|
||||
|
||||
@override
|
||||
Map<String?, List<Object>>? fromPrimitives(Object? data) {
|
||||
final Map<dynamic, dynamic> casted = data! as Map<dynamic, dynamic>;
|
||||
return casted.map<String?, List<Object>>((dynamic key, dynamic value) => MapEntry<String?, List<Object>>(
|
||||
final Map<Object?, Object?> casted = data! as Map<Object?, Object?>;
|
||||
return casted.map<String?, List<Object>>((Object? key, Object? value) => MapEntry<String?, List<Object>>(
|
||||
key as String?,
|
||||
List<Object>.from(value as List<dynamic>, growable: true),
|
||||
List<Object>.from(value! as List<Object?>, growable: true),
|
||||
));
|
||||
}
|
||||
|
||||
@ -5962,7 +5962,7 @@ class RestorableRouteFuture<T> extends RestorableProperty<String?> {
|
||||
_route = _navigator._getRouteById<T>(id);
|
||||
assert(_route != null);
|
||||
route!.restorationScopeId.addListener(notifyListeners);
|
||||
route!.popped.then((dynamic result) {
|
||||
route!.popped.then((Object? result) {
|
||||
if (_disposed) {
|
||||
return;
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didReplace(Route<dynamic>? oldRoute) {
|
||||
void didReplace(Route<Object?>? oldRoute) {
|
||||
assert(_controller != null, '$runtimeType.didReplace called before calling install() or after calling dispose().');
|
||||
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
|
||||
if (oldRoute is TransitionRoute)
|
||||
@ -243,7 +243,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didPopNext(Route<dynamic> nextRoute) {
|
||||
void didPopNext(Route<Object?> nextRoute) {
|
||||
assert(_controller != null, '$runtimeType.didPopNext called before calling install() or after calling dispose().');
|
||||
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
|
||||
_updateSecondaryAnimation(nextRoute);
|
||||
@ -251,7 +251,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeNext(Route<dynamic>? nextRoute) {
|
||||
void didChangeNext(Route<Object?>? nextRoute) {
|
||||
assert(_controller != null, '$runtimeType.didChangeNext called before calling install() or after calling dispose().');
|
||||
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
|
||||
_updateSecondaryAnimation(nextRoute);
|
||||
@ -265,14 +265,14 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
// caller must reset this property to null after it is called.
|
||||
VoidCallback? _trainHoppingListenerRemover;
|
||||
|
||||
void _updateSecondaryAnimation(Route<dynamic>? nextRoute) {
|
||||
void _updateSecondaryAnimation(Route<Object?>? nextRoute) {
|
||||
// There is an existing train hopping in progress. Unfortunately, we cannot
|
||||
// dispose current train hopping animation until we replace it with a new
|
||||
// animation.
|
||||
final VoidCallback? previousTrainHoppingListenerRemover = _trainHoppingListenerRemover;
|
||||
_trainHoppingListenerRemover = null;
|
||||
|
||||
if (nextRoute is TransitionRoute<dynamic> && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) {
|
||||
if (nextRoute is TransitionRoute<Object?> && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) {
|
||||
final Animation<double>? current = _secondaryAnimation.parent;
|
||||
if (current != null) {
|
||||
final Animation<double> currentTrain = (current is TrainHoppingAnimation ? current.currentTrain : current)!;
|
||||
@ -348,11 +348,11 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
}
|
||||
}
|
||||
|
||||
void _setSecondaryAnimation(Animation<double>? animation, [Future<dynamic>? disposed]) {
|
||||
void _setSecondaryAnimation(Animation<double>? animation, [Future<Object?>? disposed]) {
|
||||
_secondaryAnimation.parent = animation;
|
||||
// Releases the reference to the next route's animation when that route
|
||||
// is disposed.
|
||||
disposed?.then((dynamic _) {
|
||||
disposed?.then((Object? _) {
|
||||
if (_secondaryAnimation.parent == animation) {
|
||||
_secondaryAnimation.parent = kAlwaysDismissedAnimation;
|
||||
if (animation is TrainHoppingAnimation) {
|
||||
@ -386,7 +386,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
///
|
||||
/// * [canTransitionFrom], which must be true for [nextRoute] for the
|
||||
/// [ModalRoute.buildTransitions] `secondaryAnimation` to run.
|
||||
bool canTransitionTo(TransitionRoute<dynamic> nextRoute) => true;
|
||||
bool canTransitionTo(TransitionRoute<Object?> nextRoute) => true;
|
||||
|
||||
/// Returns true if [previousRoute] should animate when this route
|
||||
/// is pushed on top of it or when then this route is popped off of it.
|
||||
@ -411,7 +411,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
|
||||
///
|
||||
/// * [canTransitionTo], which must be true for [previousRoute] for its
|
||||
/// [ModalRoute.buildTransitions] `secondaryAnimation` to run.
|
||||
bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) => true;
|
||||
bool canTransitionFrom(TransitionRoute<Object?> previousRoute) => true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -437,7 +437,7 @@ class LocalHistoryEntry {
|
||||
/// Called when this entry is removed from the history of its associated [LocalHistoryRoute].
|
||||
final VoidCallback? onRemove;
|
||||
|
||||
LocalHistoryRoute<dynamic>? _owner;
|
||||
LocalHistoryRoute<Object?>? _owner;
|
||||
|
||||
/// Remove this entry from the history of its associated [LocalHistoryRoute].
|
||||
void remove() {
|
||||
@ -660,7 +660,7 @@ class _DismissModalAction extends DismissAction {
|
||||
|
||||
@override
|
||||
bool isEnabled(DismissIntent intent) {
|
||||
final ModalRoute<dynamic> route = ModalRoute.of<dynamic>(context)!;
|
||||
final ModalRoute<Object?> route = ModalRoute.of<Object?>(context)!;
|
||||
return route.barrierDismissible;
|
||||
}
|
||||
|
||||
@ -685,7 +685,7 @@ class _ModalScopeStatus extends InheritedWidget {
|
||||
|
||||
final bool isCurrent;
|
||||
final bool canPop;
|
||||
final Route<dynamic> route;
|
||||
final Route<Object?> route;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(_ModalScopeStatus old) {
|
||||
@ -934,7 +934,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
|
||||
///
|
||||
/// This function is typically used with [Navigator.popUntil()].
|
||||
static RoutePredicate withName(String name) {
|
||||
return (Route<dynamic> route) {
|
||||
return (Route<Object?> route) {
|
||||
return !route.willHandlePopInternally
|
||||
&& route is ModalRoute
|
||||
&& route.settings.name == name;
|
||||
@ -1391,7 +1391,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
|
||||
/// [State.didChangeDependencies] callback:
|
||||
///
|
||||
/// ```dart
|
||||
/// ModalRoute<dynamic> _route;
|
||||
/// ModalRoute<Object?> _route;
|
||||
///
|
||||
/// @override
|
||||
/// void didChangeDependencies() {
|
||||
@ -1464,7 +1464,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePrevious(Route<dynamic>? previousRoute) {
|
||||
void didChangePrevious(Route<Object?>? previousRoute) {
|
||||
super.didChangePrevious(previousRoute);
|
||||
changedInternalState();
|
||||
}
|
||||
@ -1613,9 +1613,9 @@ abstract class PopupRoute<T> extends ModalRoute<T> {
|
||||
/// as `always_specify_types`, the Dart analyzer will require that certain types
|
||||
/// be given with their type arguments. Since the [Route] class and its
|
||||
/// subclasses have a type argument, this includes the arguments passed to this
|
||||
/// class. Consider using `dynamic` to specify the entire class of routes rather
|
||||
/// class. Consider using `Object?` to specify the entire class of routes rather
|
||||
/// than only specific subtypes. For example, to watch for all [ModalRoute]
|
||||
/// variants, the `RouteObserver<ModalRoute<dynamic>>` type may be used.
|
||||
/// variants, the `RouteObserver<ModalRoute<Object?>>` type may be used.
|
||||
///
|
||||
/// {@tool snippet}
|
||||
///
|
||||
@ -1670,7 +1670,7 @@ abstract class PopupRoute<T> extends ModalRoute<T> {
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
class RouteObserver<R extends Route<dynamic>> extends NavigatorObserver {
|
||||
class RouteObserver<R extends Route<Object?>> extends NavigatorObserver {
|
||||
final Map<R, Set<RouteAware>> _listeners = <R, Set<RouteAware>>{};
|
||||
|
||||
/// Subscribe [routeAware] to be informed about changes to [route].
|
||||
@ -1700,7 +1700,7 @@ class RouteObserver<R extends Route<dynamic>> extends NavigatorObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
void didPop(Route<Object?> route, Route<Object?>? previousRoute) {
|
||||
if (route is R && previousRoute is R) {
|
||||
final List<RouteAware>? previousSubscribers = _listeners[previousRoute]?.toList();
|
||||
|
||||
@ -1721,7 +1721,7 @@ class RouteObserver<R extends Route<dynamic>> extends NavigatorObserver {
|
||||
}
|
||||
|
||||
@override
|
||||
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
|
||||
void didPush(Route<Object?> route, Route<Object?>? previousRoute) {
|
||||
if (route is R && previousRoute is R) {
|
||||
final Set<RouteAware>? previousSubscribers = _listeners[previousRoute];
|
||||
|
||||
|
@ -117,7 +117,7 @@ class WillPopScope extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WillPopScopeState extends State<WillPopScope> {
|
||||
ModalRoute<dynamic>? _route;
|
||||
ModalRoute<Object?>? _route;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user