Google is committed to advancing racial equity for Black communities. See how.

connect method

*<Null safety>*

Future<void> connect ({bool hitTestable: true, bool focusable: true})

Connects to the platform view given it's viewId.

Called by FuchsiaView when the platform view is ready to be initialized and should not be called directly.

Implementation

Future<void> connect({bool hitTestable = true, bool focusable = true}) async {
  if (_connected) return;

  // Setup callbacks for receiving view events.
  platformViewChannel.setMethodCallHandler((call) async {
    switch (call.method) {
      case 'View.viewConnected':
        _connected = true;
        onViewConnected?.call(this);
        break;
      case 'View.viewDisconnected':
        _connected = false;
        onViewDisconnected?.call(this);
        break;
      case 'View.viewStateChanged':
        onViewStateChanged?.call(this, call.arguments['state'] ?? false);
        break;
      default:
        print('Unknown method call from platform view channel: $call');
    }
  });

  // Now send a create message to the platform view.
  final Map<String, dynamic> args = <String, dynamic>{
    'viewId': viewId,
    'hitTestable': hitTestable,
    'focusable': focusable,
  };
  return platformViewChannel.invokeMethod('View.create', args);
}