Fix navigator 2.0 in Flutter Web (#72207)

This commit is contained in:
Jacob Moura 2020-12-21 21:19:05 -03:00 committed by GitHub
parent 4e3b01152e
commit 3335bcbe40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -666,7 +666,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
await observer.didPushRouteInformation(
RouteInformation(
location: routeArguments['location'] as String,
state: routeArguments['state'] as Object,
state: routeArguments['state'] as Object?,
)
)
)

View File

@ -129,6 +129,23 @@ void main() {
WidgetsBinding.instance!.removeObserver(observer);
});
testWidgets('didPushRouteInformation callback with null state', (WidgetTester tester) async {
final PushRouteInformationObserver observer = PushRouteInformationObserver();
WidgetsBinding.instance!.addObserver(observer);
const Map<String, dynamic> testRouteInformation = <String, dynamic>{
'location': 'testRouteName',
'state': null,
};
final ByteData message = const JSONMethodCodec().encodeMethodCall(
const MethodCall('pushRouteInformation', testRouteInformation));
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
expect(observer.pushedRouteInformation.location, 'testRouteName');
expect(observer.pushedRouteInformation.state, null);
WidgetsBinding.instance!.removeObserver(observer);
});
testWidgets('Application lifecycle affects frame scheduling', (WidgetTester tester) async {
final BinaryMessenger defaultBinaryMessenger = ServicesBinding.instance!.defaultBinaryMessenger;
ByteData message;