pushRouteNameToFramework function

Future<ByteData> pushRouteNameToFramework(
  1. Object? _,
  2. String routeName
)

Pushes the routeName into Flutter's navigation system via a platform message.

The platform is notified using SystemNavigator.routeInformationUpdated. On older versions of Flutter, this means it will not work unless the application uses a Router (e.g. using MaterialApp.router).

Returns the raw data returned by the framework.

Implementation

// TODO(ianh): Remove the first argument.
Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
  final Completer<ByteData> completer = Completer<ByteData>();
  SystemNavigator.routeInformationUpdated(uri: Uri.parse(routeName));
  ui.channelBuffers.push(
    'flutter/navigation',
    _codec.encodeMethodCall(
      MethodCall('pushRouteInformation', <dynamic, dynamic>{
        'location': routeName,
        'state': null,
      }),
    ),
    completer.complete,
  );
  return completer.future;
}