diff --git a/packages/flutter/lib/src/services/message_codecs.dart b/packages/flutter/lib/src/services/message_codecs.dart index e1784c5223..92f9d722e8 100644 --- a/packages/flutter/lib/src/services/message_codecs.dart +++ b/packages/flutter/lib/src/services/message_codecs.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - import 'dart:convert'; import 'dart:typed_data'; diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index 3d1b693785..31538bdcf6 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -8,7 +8,6 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'basic.dart'; -import 'container.dart'; import 'debug.dart'; import 'framework.dart'; import 'gesture_detector.dart'; @@ -113,10 +112,8 @@ class ModalBarrier extends StatelessWidget { opaque: true, child: ConstrainedBox( constraints: const BoxConstraints.expand(), - child: color == null ? null : DecoratedBox( - decoration: BoxDecoration( - color: color, - ), + child: color == null ? null : ColoredBox( + color: color!, ), ), ), diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 88bae80072..deef670448 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -399,20 +399,30 @@ abstract class Route { /// /// See also: /// - /// * [changedExternalState], which is called when the [Navigator] rebuilds. + /// * [changedExternalState], which is called when the [Navigator] has + /// updated in some manner that might affect the routes. @protected @mustCallSuper void changedInternalState() { } - /// Called whenever the [Navigator] has its widget rebuilt, to indicate that - /// the route may wish to rebuild as well. + /// Called whenever the [Navigator] has updated in some manner that might + /// affect routes, to indicate that the route may wish to rebuild as well. /// - /// This is called by the [Navigator] whenever the [NavigatorState]'s - /// [State.widget] changes, for example because the [MaterialApp] has been rebuilt. - /// This ensures that routes that directly refer to the state of the widget - /// that built the [MaterialApp] will be notified when that widget rebuilds, - /// since it would otherwise be difficult to notify the routes that state they - /// depend on may have changed. + /// This is called by the [Navigator] whenever the + /// [NavigatorState]'s [State.widget] changes (as in [State.didUpdateWidget]), + /// for example because the [MaterialApp] has been rebuilt. This + /// ensures that routes that directly refer to the state of the + /// widget that built the [MaterialApp] will be notified when that + /// widget rebuilds, since it would otherwise be difficult to notify + /// the routes that state they depend on may have changed. + /// + /// It is also called whenever the [Navigator]'s dependencies change + /// (as in [State.didChangeDependencies]). This allows routes to use the + /// [Navigator]'s context ([NavigatorState.context]), for example in + /// [ModalRoute.barrierColor], and update accordingly. + /// + /// The [ModalRoute] subclass overrides this to force the barrier + /// overlay to rebuild. /// /// See also: /// @@ -3442,6 +3452,8 @@ class NavigatorState extends State with TickerProviderStateMixin, Res void didChangeDependencies() { super.didChangeDependencies(); _updateHeroController(HeroControllerScope.of(context)); + for (final _RouteEntry entry in _history) + entry.route.changedExternalState(); } void _updateHeroController(HeroController? newHeroController) { diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 17ef544e8f..dc41b755ff 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -871,15 +871,14 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute true; /// {@template flutter.widgets.ModalRoute.barrierColor} @@ -1174,22 +1187,24 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute Theme.of(navigator.context).backgroundColor; /// ``` /// - /// The [Navigator] causes the [ModalRoute]'s modal barrier overlay entry - /// to rebuild any time its dependencies change. - /// /// {@end-tool} /// /// See also: @@ -1213,9 +1228,14 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute