diff --git a/packages/flutter/lib/src/widgets/router.dart b/packages/flutter/lib/src/widgets/router.dart index d8d0d1a649..8610aa2ce6 100644 --- a/packages/flutter/lib/src/widgets/router.dart +++ b/packages/flutter/lib/src/widgets/router.dart @@ -491,7 +491,7 @@ class _RouterState extends State> with RestorationMixin { if (_routeInformation.value != null) { _processRouteInformation(_routeInformation.value!, () => widget.routerDelegate.setRestoredRoutePath); } else if (widget.routeInformationProvider != null) { - _processRouteInformation(widget.routeInformationProvider!.value!, () => widget.routerDelegate.setInitialRoutePath); + _processRouteInformation(widget.routeInformationProvider!.value, () => widget.routerDelegate.setInitialRoutePath); } } @@ -632,7 +632,7 @@ class _RouterState extends State> with RestorationMixin { void _handleRouteInformationProviderNotification() { assert(widget.routeInformationProvider!.value != null); - _processRouteInformation(widget.routeInformationProvider!.value!, () => widget.routerDelegate.setNewRoutePath); + _processRouteInformation(widget.routeInformationProvider!.value, () => widget.routerDelegate.setNewRoutePath); } Future _handleBackButtonDispatcherNotification() { @@ -1300,7 +1300,7 @@ abstract class RouterDelegate extends Listenable { /// intent to the [Router] widget, as well as reports new route information /// from the [Router] back to the engine by overriding the /// [routerReportsNewRouteInformation]. -abstract class RouteInformationProvider extends ValueListenable { +abstract class RouteInformationProvider extends ValueListenable { /// A callback called when the [Router] widget detects any navigation event /// due to state changes. /// @@ -1329,7 +1329,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid /// Use the [initialRouteInformation] to set the default route information for this /// provider. PlatformRouteInformationProvider({ - RouteInformation? initialRouteInformation, + required RouteInformation initialRouteInformation, }) : _value = initialRouteInformation; @override @@ -1343,8 +1343,8 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid } @override - RouteInformation? get value => _value; - RouteInformation? _value; + RouteInformation get value => _value; + RouteInformation _value; void _platformReportsNewRouteInformation(RouteInformation routeInformation) { if (_value == routeInformation) diff --git a/packages/flutter/test/widgets/router_restoration_test.dart b/packages/flutter/test/widgets/router_restoration_test.dart index 22f161954c..115f945687 100644 --- a/packages/flutter/test/widgets/router_restoration_test.dart +++ b/packages/flutter/test/widgets/router_restoration_test.dart @@ -129,9 +129,9 @@ class _TestRouterDelegate extends RouterDelegate with ChangeNotifier { class _TestRouteInformationProvider extends RouteInformationProvider with ChangeNotifier { @override - RouteInformation? get value => _value; - RouteInformation? _value = const RouteInformation(location: '/home'); - set value(RouteInformation? value) { + RouteInformation get value => _value; + RouteInformation _value = const RouteInformation(location: '/home'); + set value(RouteInformation value) { if (value == _value) { return; }