create method

  1. @override
Future<void> create(
  1. {Size? size,
  2. Offset? position}
)
override

Creates the platform view with the initial size.

size is the view's initial size in logical pixel. size can be omitted if the concrete implementation doesn't require an initial size to create the platform view.

position is the view's initial position in logical pixels. position can be omitted if the concrete implementation doesn't require an initial position.

Implementation

@override
Future<void> create({Size? size, Offset? position}) async {
  assert(_state != _AndroidViewState.disposed, 'trying to create a disposed Android view');
  assert(_state == _AndroidViewState.waitingForSize, 'Android view is already sized. View id: $viewId');

  if (_createRequiresSize && size == null) {
    // Wait for a setSize call.
    return;
  }

  _state = _AndroidViewState.creating;
  await _sendCreateMessage(size: size, position: position);
  _state = _AndroidViewState.created;

  for (final PlatformViewCreatedCallback callback in _platformViewCreatedCallbacks) {
    callback(viewId);
  }
}