Unverified Commit a6765938 authored by chunhtai's avatar chunhtai Committed by GitHub

relax routerReportsNewRouteInformation function signature (#97154)

parent a88888e4
...@@ -1326,7 +1326,7 @@ abstract class RouteInformationProvider extends ValueListenable<RouteInformation ...@@ -1326,7 +1326,7 @@ abstract class RouteInformationProvider extends ValueListenable<RouteInformation
/// For more information on how [Router] determines a navigation event, see /// For more information on how [Router] determines a navigation event, see
/// the "URL updates for web applications" section in the [Router] /// the "URL updates for web applications" section in the [Router]
/// documentation. /// documentation.
void routerReportsNewRouteInformation(RouteInformation routeInformation, {required RouteInformationReportingType type}) {} void routerReportsNewRouteInformation(RouteInformation routeInformation, {RouteInformationReportingType type = RouteInformationReportingType.none}) {}
} }
/// The route information provider that propagates the platform route information changes. /// The route information provider that propagates the platform route information changes.
...@@ -1349,7 +1349,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid ...@@ -1349,7 +1349,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid
}) : _value = initialRouteInformation; }) : _value = initialRouteInformation;
@override @override
void routerReportsNewRouteInformation(RouteInformation routeInformation, {required RouteInformationReportingType type}) { void routerReportsNewRouteInformation(RouteInformation routeInformation, {RouteInformationReportingType type = RouteInformationReportingType.none}) {
final bool replace = final bool replace =
type == RouteInformationReportingType.neglect || type == RouteInformationReportingType.neglect ||
(type == RouteInformationReportingType.none && (type == RouteInformationReportingType.none &&
......
...@@ -802,14 +802,14 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester ...@@ -802,14 +802,14 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester
); );
log.clear(); log.clear();
provider.routerReportsNewRouteInformation(const RouteInformation(location: 'a', state: true), type: RouteInformationReportingType.none); provider.routerReportsNewRouteInformation(const RouteInformation(location: 'a', state: true));
// Implicit reporting pushes new history entry if the location changes. // Implicit reporting pushes new history entry if the location changes.
expect(log, <Object>[ expect(log, <Object>[
isMethodCall('selectMultiEntryHistory', arguments: null), isMethodCall('selectMultiEntryHistory', arguments: null),
isMethodCall('routeInformationUpdated', arguments: <String, dynamic>{ 'location': 'a', 'state': true, 'replace': false }), isMethodCall('routeInformationUpdated', arguments: <String, dynamic>{ 'location': 'a', 'state': true, 'replace': false }),
]); ]);
log.clear(); log.clear();
provider.routerReportsNewRouteInformation(const RouteInformation(location: 'a', state: false), type: RouteInformationReportingType.none); provider.routerReportsNewRouteInformation(const RouteInformation(location: 'a', state: false));
// Since the location is the same, the provider sends replaces message. // Since the location is the same, the provider sends replaces message.
expect(log, <Object>[ expect(log, <Object>[
isMethodCall('selectMultiEntryHistory', arguments: null), isMethodCall('selectMultiEntryHistory', arguments: null),
...@@ -1392,7 +1392,7 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang ...@@ -1392,7 +1392,7 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang
} }
@override @override
void routerReportsNewRouteInformation(RouteInformation routeInformation, {required RouteInformationReportingType type}) { void routerReportsNewRouteInformation(RouteInformation routeInformation, {RouteInformationReportingType type = RouteInformationReportingType.none}) {
_value = routeInformation; _value = routeInformation;
onRouterReport?.call(routeInformation, type); onRouterReport?.call(routeInformation, type);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment