diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index dbc226de9b..163922a8c3 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -789,7 +789,7 @@ class _AppBarState extends State { final ColorScheme colorScheme = theme.colorScheme; final AppBarTheme appBarTheme = AppBarTheme.of(context); final ScaffoldState? scaffold = Scaffold.maybeOf(context); - final ModalRoute? parentRoute = ModalRoute.of(context); + final ModalRoute? parentRoute = ModalRoute.of(context); final FlexibleSpaceBarSettings? settings = context.dependOnInheritedWidgetOfExactType(); final Set states = { @@ -799,7 +799,7 @@ class _AppBarState extends State { final bool hasDrawer = scaffold?.hasDrawer ?? false; final bool hasEndDrawer = scaffold?.hasEndDrawer ?? false; final bool canPop = parentRoute?.canPop ?? false; - final bool useCloseButton = parentRoute is PageRoute && parentRoute.fullscreenDialog; + final bool useCloseButton = parentRoute is PageRoute && parentRoute.fullscreenDialog; final double toolbarHeight = widget.toolbarHeight ?? appBarTheme.toolbarHeight ?? kToolbarHeight; final bool backwardsCompatibility = widget.backwardsCompatibility ?? appBarTheme.backwardsCompatibility ?? true; diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index cf9d1b0401..582f571b48 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -363,7 +363,7 @@ class DrawerControllerState extends State with SingleTickerPro void _ensureHistoryEntry() { if (_historyEntry == null) { - final ModalRoute? route = ModalRoute.of(context); + final ModalRoute? route = ModalRoute.of(context); if (route != null) { _historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved); route.addLocalHistoryEntry(_historyEntry!); diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 09157634dd..dabad88834 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -452,7 +452,7 @@ class ScaffoldMessengerState extends State with TickerProvide _accessibleNavigation = mediaQuery.accessibleNavigation; if (_snackBars.isNotEmpty) { - final ModalRoute? route = ModalRoute.of(context); + final ModalRoute? 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 with TickerProviderStateMixin, Resto // Important if the app/user takes an action that could repeatedly show a // bottom sheet. final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[]; - PersistentBottomSheetController? _currentBottomSheet; + PersistentBottomSheetController? _currentBottomSheet; final GlobalKey _currentBottomSheetKey = GlobalKey(); void _maybeBuildPersistentBottomSheet() { @@ -2981,7 +2981,7 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto // TODO(Piinks): Remove old SnackBar API after migrating ScaffoldMessenger _accessibleNavigation = mediaQuery.accessibleNavigation; if (_snackBars.isNotEmpty) { - final ModalRoute? route = ModalRoute.of(context); + final ModalRoute? route = ModalRoute.of(context); if (route == null || route.isCurrent) { if (_snackBarController!.isCompleted && _snackBarTimer == null) { final SnackBar snackBar = _snackBars.first._widget; diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index 57028bd356..fd1c8cdd45 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -487,8 +487,8 @@ class _HeroFlightManifest { final HeroFlightDirection type; final OverlayState overlay; final Size navigatorSize; - final PageRoute fromRoute; - final PageRoute toRoute; + final PageRoute fromRoute; + final PageRoute toRoute; final _HeroState fromHero; final _HeroState toHero; final CreateRectTween? createRectTween; @@ -830,14 +830,14 @@ class HeroController extends NavigatorObserver { final Map _flights = {}; @override - void didPush(Route route, Route? previousRoute) { + void didPush(Route route, Route? previousRoute) { assert(navigator != null); assert(route != null); _maybeStartHeroTransition(previousRoute, route, HeroFlightDirection.push, false); } @override - void didPop(Route route, Route? previousRoute) { + void didPop(Route route, Route? 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? newRoute, Route? oldRoute }) { + void didReplace({ Route? newRoute, Route? 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 route, Route? previousRoute) { + void didStartUserGesture(Route route, Route? 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? fromRoute, - Route? toRoute, + Route? fromRoute, + Route? toRoute, HeroFlightDirection flightType, bool isUserGestureTransition, ) { - if (toRoute != fromRoute && toRoute is PageRoute && fromRoute is PageRoute) { - final PageRoute from = fromRoute; - final PageRoute to = toRoute; + if (toRoute != fromRoute && toRoute is PageRoute && fromRoute is PageRoute) { + final PageRoute from = fromRoute; + final PageRoute to = toRoute; final Animation 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 from, - PageRoute to, + PageRoute from, + PageRoute to, Animation animation, HeroFlightDirection flightType, bool isUserGestureTransition, diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 0426044ae8..90c6e9f501 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -38,12 +38,12 @@ import 'ticker_provider.dart'; /// See also: /// /// * [Navigator], which is where all the [Route]s end up. -typedef RouteFactory = Route? Function(RouteSettings settings); +typedef RouteFactory = Route? Function(RouteSettings settings); /// Creates a series of one or more routes. /// /// Used by [Navigator.onGenerateInitialRoutes]. -typedef RouteListFactory = List> Function(NavigatorState navigator, String initialRoute); +typedef RouteListFactory = List> Function(NavigatorState navigator, String initialRoute); /// Creates a [Route] that is to be added to a [Navigator]. /// @@ -58,7 +58,7 @@ typedef RouteListFactory = List> Function(NavigatorState navigato typedef RestorableRouteBuilder = Route Function(BuildContext context, Object? arguments); /// Signature for the [Navigator.popUntil] predicate argument. -typedef RoutePredicate = bool Function(Route route); +typedef RoutePredicate = bool Function(Route route); /// Signature for a callback that verifies that it's OK to call [Navigator.pop]. /// @@ -73,7 +73,7 @@ typedef WillPopCallback = Future 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 route, dynamic result); +typedef PopPageCallback = bool Function(Route route, Object? result); /// Indicates whether the current route should be popped. /// @@ -260,7 +260,7 @@ abstract class Route { /// immediately after this method is called. @protected @mustCallSuper - void didReplace(Route? oldRoute) { } + void didReplace(Route? oldRoute) { } /// Returns whether calling [Navigator.maybePop] when this [Route] is current /// ([isCurrent]) should do anything. @@ -362,7 +362,7 @@ abstract class Route { /// is no next route. @protected @mustCallSuper - void didPopNext(Route nextRoute) { } + void didPopNext(Route nextRoute) { } /// This route's next route has changed to the given new route. /// @@ -375,7 +375,7 @@ abstract class Route { /// if [isCurrent] is true). @protected @mustCallSuper - void didChangeNext(Route? nextRoute) { } + void didChangeNext(Route? nextRoute) { } /// This route's previous route has changed to the given new route. /// @@ -388,7 +388,7 @@ abstract class Route { /// (i.e. if [isFirst] is true). @protected @mustCallSuper - void didChangePrevious(Route? previousRoute) { } + void didChangePrevious(Route? previousRoute) { } /// Called whenever the internal state of the route has changed. /// @@ -588,7 +588,7 @@ abstract class Page extends RouteSettings { /// /// Two pages are consider updatable if they have same the [runtimeType] and /// [key]. - bool canUpdate(Page other) { + bool canUpdate(Page 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 route, Route? previousRoute) { } + void didPush(Route route, Route? previousRoute) { } /// The [Navigator] popped `route`. /// /// The route immediately below that one, and thus the newly active /// route, is `previousRoute`. - void didPop(Route route, Route? previousRoute) { } + void didPop(Route route, Route? 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 route, Route? previousRoute) { } + void didRemove(Route route, Route? previousRoute) { } /// The [Navigator] replaced `oldRoute` with `newRoute`. - void didReplace({ Route? newRoute, Route? oldRoute }) { } + void didReplace({ Route? newRoute, Route? 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 route, Route? previousRoute) { } + void didStartUserGesture(Route route, Route? 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 get route; + Route 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 >[], + this.pages = const >[], this.onPopPage, this.initialRoute, this.onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes, this.onGenerateRoute, this.onUnknownRoute, - this.transitionDelegate = const DefaultTransitionDelegate(), + this.transitionDelegate = const DefaultTransitionDelegate(), this.reportsRouteUpdateToEngine = false, this.observers = const [], 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> pages; + final List> 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 transitionDelegate; + final TransitionDelegate 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 route) => false`). + /// that always returns false (e.g. `(Route 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 route) => false`). + /// that always returns false (e.g. `(Route 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(BuildContext context, { required Route oldRoute, required Route newRoute }) { + static void replace(BuildContext context, { required Route oldRoute, required Route newRoute }) { return Navigator.of(context).replace(oldRoute: oldRoute, newRoute: newRoute); } @@ -2448,7 +2448,7 @@ class Navigator extends StatefulWidget { /// /// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue} @optionalTypeArgs - static String restorableReplace(BuildContext context, { required Route oldRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { + static String restorableReplace(BuildContext context, { required Route oldRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { return Navigator.of(context).restorableReplace(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(BuildContext context, { required Route anchorRoute, required Route newRoute }) { + static void replaceRouteBelow(BuildContext context, { required Route anchorRoute, required Route newRoute }) { return Navigator.of(context).replaceRouteBelow(anchorRoute: anchorRoute, newRoute: newRoute); } @@ -2504,7 +2504,7 @@ class Navigator extends StatefulWidget { /// /// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue} @optionalTypeArgs - static String restorableReplaceRouteBelow(BuildContext context, { required Route anchorRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { + static String restorableReplaceRouteBelow(BuildContext context, { required Route anchorRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { return Navigator.of(context).restorableReplaceRouteBelow(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 route) { + static void removeRoute(BuildContext context, Route 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 anchorRoute) { + static void removeRouteBelow(BuildContext context, Route 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> defaultGenerateInitialRoutes(NavigatorState navigator, String initialRouteName) { - final List?> result = ?>[]; + static List> defaultGenerateInitialRoutes(NavigatorState navigator, String initialRouteName) { + final List?> result = ?>[]; if (initialRouteName.startsWith('/') && initialRouteName.length > 1) { initialRouteName = initialRouteName.substring(1); // strip leading '/' assert(Navigator.defaultRouteName == '/'); @@ -2801,7 +2801,7 @@ class Navigator extends StatefulWidget { debugRouteNames = [ Navigator.defaultRouteName ]; return true; }()); - result.add(navigator._routeNamed(Navigator.defaultRouteName, arguments: null, allowNull: true)); + result.add(navigator._routeNamed(Navigator.defaultRouteName, arguments: null, allowNull: true)); final List 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(routeName, arguments: null, allowNull: true)); + result.add(navigator._routeNamed(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(initialRouteName, arguments: null, allowNull: true)); + result.add(navigator._routeNamed(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? route) => route == null); + result.removeWhere((Route? route) => route == null); if (result.isEmpty) - result.add(navigator._routeNamed(Navigator.defaultRouteName, arguments: null)); - return result.cast>(); + result.add(navigator._routeNamed(Navigator.defaultRouteName, arguments: null)); + return result.cast>(); } @override @@ -2946,15 +2946,15 @@ class _RouteEntry extends RouteTransitionRecord { currentState = initialState; @override - final Route route; + final Route route; final _RestorationInformation? restorationInformation; - static Route notAnnounced = _NotAnnounced(); + static Route notAnnounced = _NotAnnounced(); _RouteLifecycle currentState; - Route? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious - Route lastAnnouncedPoppedNextRoute = notAnnounced; // last argument to Route.didPopNext - Route? lastAnnouncedNextRoute = notAnnounced; // last argument to Route.didChangeNext + Route? lastAnnouncedPreviousRoute = notAnnounced; // last argument to Route.didChangePrevious + Route lastAnnouncedPoppedNextRoute = notAnnounced; // last argument to Route.didPopNext + Route? 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 page) { + bool canUpdateFrom(Page page) { if (currentState.index > _RouteLifecycle.idle.index) return false; if (!hasPage) return false; - final Page routePage = route.settings as Page; + final Page routePage = route.settings as Page; return page.canUpdate(routePage); } - void handleAdd({ required NavigatorState navigator, required Route? previousPresent }) { + void handleAdd({ required NavigatorState navigator, required Route? 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? previous, required Route? previousPresent }) { + void handlePush({ required NavigatorState navigator, required bool isNewFirst, required Route? previous, required Route? 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 poppedRoute) { + void handleDidPopNext(Route poppedRoute) { route.didPopNext(poppedRoute); lastAnnouncedPoppedNextRoute = poppedRoute; } - void handlePop({ required NavigatorState navigator, required Route? previousPresent }) { + void handlePop({ required NavigatorState navigator, required Route? 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? previousPresent }) { + void handleRemoval({ required NavigatorState navigator, required Route? 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? nextRoute) { + bool shouldAnnounceChangeToNext(Route? 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 route) { + static _RouteEntryPredicate isRoutePredicate(Route 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(result); + pop(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(result); + complete(result); _isWaitingForExitingDecision = false; } @@ -3276,16 +3276,16 @@ abstract class _NavigatorObservation { this.primaryRoute, this.secondaryRoute, ); - final Route primaryRoute; - final Route? secondaryRoute; + final Route primaryRoute; + final Route? secondaryRoute; void notify(NavigatorObserver observer); } class _NavigatorPushObservation extends _NavigatorObservation { _NavigatorPushObservation( - Route primaryRoute, - Route? secondaryRoute, + Route primaryRoute, + Route? secondaryRoute, ) : super(primaryRoute, secondaryRoute); @override @@ -3296,8 +3296,8 @@ class _NavigatorPushObservation extends _NavigatorObservation { class _NavigatorPopObservation extends _NavigatorObservation { _NavigatorPopObservation( - Route primaryRoute, - Route? secondaryRoute, + Route primaryRoute, + Route? secondaryRoute, ) : super(primaryRoute, secondaryRoute); @override @@ -3308,8 +3308,8 @@ class _NavigatorPopObservation extends _NavigatorObservation { class _NavigatorRemoveObservation extends _NavigatorObservation { _NavigatorRemoveObservation( - Route primaryRoute, - Route? secondaryRoute, + Route primaryRoute, + Route? secondaryRoute, ) : super(primaryRoute, secondaryRoute); @override @@ -3320,8 +3320,8 @@ class _NavigatorRemoveObservation extends _NavigatorObservation { class _NavigatorReplaceObservation extends _NavigatorObservation { _NavigatorReplaceObservation( - Route primaryRoute, - Route? secondaryRoute, + Route primaryRoute, + Route? secondaryRoute, ) : super(primaryRoute, secondaryRoute); @override @@ -3353,7 +3353,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res void initState() { super.initState(); assert((){ - if (widget.pages != const >[]) { + if (widget.pages != const >[]) { // This navigator uses page API. if (widget.pages.isEmpty) { FlutterError.reportError( @@ -3414,7 +3414,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res // Populate the new history from restoration data. _history.addAll(_serializableHistory.restoreEntriesForPage(null, this)); - for (final Page page in widget.pages) { + for (final Page page in widget.pages) { final _RouteEntry entry = _RouteEntry( page.createRoute(context), initialState: _RouteLifecycle.add, @@ -3439,7 +3439,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res widget.onGenerateInitialRoutes( this, widget.initialRoute ?? Navigator.defaultRouteName, - ).map((Route route) => _RouteEntry( + ).map((Route route) => _RouteEntry( route, initialState: _RouteLifecycle.add, restorationInformation: route.settings.name != null @@ -3550,7 +3550,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res void didUpdateWidget(Navigator oldWidget) { super.didUpdateWidget(oldWidget); assert((){ - if (widget.pages != const >[]) { + if (widget.pages != const >[]) { // This navigator uses page API. if (widget.pages.isEmpty) { FlutterError.reportError( @@ -3613,7 +3613,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res void _debugCheckDuplicatedPageKeys() { assert((){ final Set keyReservation = {}; - for (final Page page in widget.pages) { + for (final Page page in widget.pages) { final LocalKey? key = page.key; if (key != null) { assert(!keyReservation.contains(key)); @@ -3726,7 +3726,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res } if (newPagesBottom > newPagesTop) break; - final Page newPage = widget.pages[newPagesBottom]; + final Page newPage = widget.pages[newPagesBottom]; if (!oldEntry.canUpdateFrom(newPage)) break; previousOldPageRouteEntry = oldEntry; @@ -3748,7 +3748,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res oldEntriesTop -= 1; continue; } - final Page newPage = widget.pages[newPagesTop]; + final Page 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 with TickerProviderStateMixin, Res assert(oldEntry.hasPage); - final Page page = oldEntry.route.settings as Page; + final Page page = oldEntry.route.settings as Page; if (page.key == null) continue; @@ -3787,7 +3787,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res // Updates the middle of the list. while (newPagesBottom <= newPagesTop) { - final Page nextPage = widget.pages[newPagesBottom]; + final Page nextPage = widget.pages[newPagesBottom]; newPagesBottom += 1; if ( nextPage.key == null || @@ -3836,7 +3836,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res continue; } - final Page potentialPageToRemove = potentialEntryToRemove.route.settings as Page; + final Page potentialPageToRemove = potentialEntryToRemove.route.settings as Page; // 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 with TickerProviderStateMixin, Res continue; } previousOldPageRouteEntry = oldEntry; - final Page newPage = widget.pages[newPagesBottom]; + final Page newPage = widget.pages[newPagesBottom]; assert(oldEntry.canUpdateFrom(newPage)); oldEntry.route._updateSettings(newPage); newHistory.add(oldEntry); @@ -3928,7 +3928,7 @@ class NavigatorState extends State 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? poppedRoute; // The route that should trigger didPopNext on the top active route. + Route? 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 with TickerProviderStateMixin, Res return route.popped; } - bool _debugCheckIsPagelessRoute(Route route) { + bool _debugCheckIsPagelessRoute(Route route) { assert((){ if (route.settings is Page) { FlutterError.reportError( @@ -4578,19 +4578,19 @@ class NavigatorState extends State with TickerProviderStateMixin, Res _afterNavigation(entry.route); } - void _afterNavigation(Route? route) { + void _afterNavigation(Route? 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? routeJsonable; + Map? routeJsonable; if (route != null) { - routeJsonable = {}; + routeJsonable = {}; final String description; - if (route is TransitionRoute) { - final TransitionRoute transitionRoute = route; + if (route is TransitionRoute) { + final TransitionRoute transitionRoute = route; description = transitionRoute.debugLabel; } else { description = '$route'; @@ -4598,7 +4598,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res routeJsonable['description'] = description; final RouteSettings settings = route.settings; - final Map settingsJsonable = { + final Map settingsJsonable = { 'name': settings.name, }; if (settings.arguments != null) { @@ -4610,7 +4610,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res routeJsonable['settings'] = settingsJsonable; } - developer.postEvent('Flutter.Navigation', { + developer.postEvent('Flutter.Navigation', { 'route': routeJsonable, }); } @@ -4852,7 +4852,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// * [restorableReplace], which adds a replacement route that can be /// restored during state restoration. @optionalTypeArgs - void replace({ required Route oldRoute, required Route newRoute }) { + void replace({ required Route oldRoute, required Route newRoute }) { assert(!_debugLocked); assert(oldRoute != null); assert(oldRoute._navigator == this); @@ -4870,7 +4870,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// /// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue} @optionalTypeArgs - String restorableReplace({ required Route oldRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { + String restorableReplace({ required Route oldRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { assert(oldRoute != null); assert(oldRoute._navigator == this); assert(newRouteBuilder != null); @@ -4886,7 +4886,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res return entry.restorationId!; } - void _replaceEntry(_RouteEntry entry, Route oldRoute) { + void _replaceEntry(_RouteEntry entry, Route oldRoute) { assert(!_debugLocked); if (oldRoute == entry.route) return; @@ -4923,7 +4923,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// * [restorableReplaceRouteBelow], which adds a replacement route that can /// be restored during state restoration. @optionalTypeArgs - void replaceRouteBelow({ required Route anchorRoute, required Route newRoute }) { + void replaceRouteBelow({ required Route anchorRoute, required Route newRoute }) { assert(newRoute != null); assert(newRoute._navigator == null); assert(anchorRoute != null); @@ -4942,7 +4942,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// /// {@macro flutter.widgets.Navigator.restorablePushNamed.returnValue} @optionalTypeArgs - String restorableReplaceRouteBelow({ required Route anchorRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { + String restorableReplaceRouteBelow({ required Route anchorRoute, required RestorableRouteBuilder newRouteBuilder, Object? arguments }) { assert(anchorRoute != null); assert(anchorRoute._navigator == this); assert(newRouteBuilder != null); @@ -4958,7 +4958,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res return entry.restorationId!; } - void _replaceEntryBelow(_RouteEntry entry, Route anchorRoute) { + void _replaceEntryBelow(_RouteEntry entry, Route anchorRoute) { assert(!_debugLocked); assert(() { _debugLocked = true; return true; }()); final int anchorIndex = _history.indexWhere(_RouteEntry.isRoutePredicate(anchorRoute)); @@ -5122,7 +5122,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// Immediately remove `route` from the navigator, and [Route.dispose] it. /// /// {@macro flutter.widgets.navigator.removeRoute} - void removeRoute(Route route) { + void removeRoute(Route route) { assert(route != null); assert(!_debugLocked); assert(() { @@ -5152,7 +5152,7 @@ class NavigatorState extends State with TickerProviderStateMixin, Res /// route to be removed is the one below the given `anchorRoute`. /// /// {@macro flutter.widgets.navigator.removeRouteBelow} - void removeRouteBelow(Route anchorRoute) { + void removeRouteBelow(Route anchorRoute) { assert(!_debugLocked); assert(() { _debugLocked = true; @@ -5189,7 +5189,7 @@ class NavigatorState extends State 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 route) { + void finalizeRoute(Route 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 with TickerProviderStateMixin, Res _RouteEntry.willBePresentPredicate, ); assert(routeIndex != null); - final Route route = _history[routeIndex].route; - Route? previousRoute; + final Route route = _history[routeIndex].route; + Route? previousRoute; if (!route.willHandlePopInternally && routeIndex > 0) { previousRoute = _getRouteBefore( routeIndex - 1, @@ -5382,7 +5382,7 @@ abstract class _RestorationInformation { } @protected - Route createRoute(NavigatorState navigator); + Route 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 createRoute(NavigatorState navigator) { - final Route route = navigator._routeNamed(name, arguments: arguments, allowNull: false)!; + Route createRoute(NavigatorState navigator) { + final Route route = navigator._routeNamed(name, arguments: arguments, allowNull: false)!; assert(route != null); return route; } @@ -5476,8 +5476,8 @@ class _AnonymousRestorationInformation extends _RestorationInformation { final Object? arguments; @override - Route createRoute(NavigatorState navigator) { - final Route result = routeBuilder(navigator.context, arguments); + Route createRoute(NavigatorState navigator) { + final Route result = routeBuilder(navigator.context, arguments); assert(result != null); return result; } @@ -5621,10 +5621,10 @@ class _HistoryProperty extends RestorableProperty>?> { @override Map>? fromPrimitives(Object? data) { - final Map casted = data! as Map; - return casted.map>((dynamic key, dynamic value) => MapEntry>( + final Map casted = data! as Map; + return casted.map>((Object? key, Object? value) => MapEntry>( key as String?, - List.from(value as List, growable: true), + List.from(value! as List, growable: true), )); } @@ -5962,7 +5962,7 @@ class RestorableRouteFuture extends RestorableProperty { _route = _navigator._getRouteById(id); assert(_route != null); route!.restorationScopeId.addListener(notifyListeners); - route!.popped.then((dynamic result) { + route!.popped.then((Object? result) { if (_disposed) { return; } diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index c2778269cf..1824bce45b 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -225,7 +225,7 @@ abstract class TransitionRoute extends OverlayRoute { } @override - void didReplace(Route? oldRoute) { + void didReplace(Route? 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 extends OverlayRoute { } @override - void didPopNext(Route nextRoute) { + void didPopNext(Route 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 extends OverlayRoute { } @override - void didChangeNext(Route? nextRoute) { + void didChangeNext(Route? 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 extends OverlayRoute { // caller must reset this property to null after it is called. VoidCallback? _trainHoppingListenerRemover; - void _updateSecondaryAnimation(Route? nextRoute) { + void _updateSecondaryAnimation(Route? 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 && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) { + if (nextRoute is TransitionRoute && canTransitionTo(nextRoute) && nextRoute.canTransitionFrom(this)) { final Animation? current = _secondaryAnimation.parent; if (current != null) { final Animation currentTrain = (current is TrainHoppingAnimation ? current.currentTrain : current)!; @@ -348,11 +348,11 @@ abstract class TransitionRoute extends OverlayRoute { } } - void _setSecondaryAnimation(Animation? animation, [Future? disposed]) { + void _setSecondaryAnimation(Animation? animation, [Future? 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 extends OverlayRoute { /// /// * [canTransitionFrom], which must be true for [nextRoute] for the /// [ModalRoute.buildTransitions] `secondaryAnimation` to run. - bool canTransitionTo(TransitionRoute nextRoute) => true; + bool canTransitionTo(TransitionRoute 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 extends OverlayRoute { /// /// * [canTransitionTo], which must be true for [previousRoute] for its /// [ModalRoute.buildTransitions] `secondaryAnimation` to run. - bool canTransitionFrom(TransitionRoute previousRoute) => true; + bool canTransitionFrom(TransitionRoute 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? _owner; + LocalHistoryRoute? _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 route = ModalRoute.of(context)!; + final ModalRoute route = ModalRoute.of(context)!; return route.barrierDismissible; } @@ -685,7 +685,7 @@ class _ModalScopeStatus extends InheritedWidget { final bool isCurrent; final bool canPop; - final Route route; + final Route route; @override bool updateShouldNotify(_ModalScopeStatus old) { @@ -934,7 +934,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute route) { + return (Route route) { return !route.willHandlePopInternally && route is ModalRoute && route.settings.name == name; @@ -1391,7 +1391,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute _route; + /// ModalRoute _route; /// /// @override /// void didChangeDependencies() { @@ -1464,7 +1464,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute? previousRoute) { + void didChangePrevious(Route? previousRoute) { super.didChangePrevious(previousRoute); changedInternalState(); } @@ -1613,9 +1613,9 @@ abstract class PopupRoute extends ModalRoute { /// 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>` type may be used. +/// variants, the `RouteObserver>` type may be used. /// /// {@tool snippet} /// @@ -1670,7 +1670,7 @@ abstract class PopupRoute extends ModalRoute { /// } /// ``` /// {@end-tool} -class RouteObserver> extends NavigatorObserver { +class RouteObserver> extends NavigatorObserver { final Map> _listeners = >{}; /// Subscribe [routeAware] to be informed about changes to [route]. @@ -1700,7 +1700,7 @@ class RouteObserver> extends NavigatorObserver { } @override - void didPop(Route route, Route? previousRoute) { + void didPop(Route route, Route? previousRoute) { if (route is R && previousRoute is R) { final List? previousSubscribers = _listeners[previousRoute]?.toList(); @@ -1721,7 +1721,7 @@ class RouteObserver> extends NavigatorObserver { } @override - void didPush(Route route, Route? previousRoute) { + void didPush(Route route, Route? previousRoute) { if (route is R && previousRoute is R) { final Set? previousSubscribers = _listeners[previousRoute]; diff --git a/packages/flutter/lib/src/widgets/will_pop_scope.dart b/packages/flutter/lib/src/widgets/will_pop_scope.dart index 5985fa86fd..da37265a3f 100644 --- a/packages/flutter/lib/src/widgets/will_pop_scope.dart +++ b/packages/flutter/lib/src/widgets/will_pop_scope.dart @@ -117,7 +117,7 @@ class WillPopScope extends StatefulWidget { } class _WillPopScopeState extends State { - ModalRoute? _route; + ModalRoute? _route; @override void didChangeDependencies() {