defaultBinaryMessenger top-level property

BinaryMessenger defaultBinaryMessenger
@Deprecated('Use ServicesBinding.instance.defaultBinaryMessenger instead. ' 'This feature was deprecated after v1.6.5.')

The default instance of BinaryMessenger.

This API has been deprecated in favor of ServicesBinding.defaultBinaryMessenger. Please use ServicesBinding.defaultBinaryMessenger as the default instance of BinaryMessenger.

This is used to send messages from the application to the platform, and keeps track of which handlers have been registered on each channel so it may dispatch incoming messages to the registered handler.

Implementation

@Deprecated(
  'Use ServicesBinding.instance.defaultBinaryMessenger instead. '
  'This feature was deprecated after v1.6.5.'
)
BinaryMessenger get defaultBinaryMessenger {
  assert(() {
    if (ServicesBinding.instance == null) {
      throw FlutterError(
        'ServicesBinding.defaultBinaryMessenger was accessed before the '
        'binding was initialized.\n'
        'If you\'re running an application and need to access the binary '
        'messenger before `runApp()` has been called (for example, during '
        'plugin initialization), then you need to explicitly call the '
        '`WidgetsFlutterBinding.ensureInitialized()` first.\n'
        'If you\'re running a test, you can call the '
        '`TestWidgetsFlutterBinding.ensureInitialized()` as the first line in '
        'your test\'s `main()` method to initialize the binding.'
      );
    }
    return true;
  }());
  return ServicesBinding.instance.defaultBinaryMessenger;
}