handleFrameworkMessage method Null safety

Future<void> handleFrameworkMessage(
  1. String channel,
  2. ByteData? data,
  3. PlatformMessageResponseCallback? callback

Message handler for web plugins.

This method is called when handling messages from the framework.

If a handler has been registered for the given channel, it is invoked, and the value it returns is passed to callback (if that is non-null). Then, the method's future is completed.

If no handler has been registered for that channel, then the callback (if any) is invoked with null, then the method's future is completed.

Messages are not buffered (unlike platform messages headed to the framework, which are managed by ChannelBuffers).

This method is registered as the message handler by code autogenerated by the flutter tool when the application is compiled, if any web plugins are used. The code in question is the following:



Future<void> handleFrameworkMessage(
  String channel,
  ByteData? data,
  ui.PlatformMessageResponseCallback? callback,
) async {
  ByteData? response;
  try {
    final MessageHandler? handler = _handlers[channel];
    if (handler != null) {
      response = await handler(data);
  } catch (exception, stack) {
      exception: exception,
      stack: stack,
      library: 'flutter web plugins',
      context: ErrorDescription('during a framework-to-plugin message'),
  } finally {
    if (callback != null) {