setSize method Null safety

Future<Size> setSize(
  1. Size size
)

Sizes the Android View.

size is the view's new size in logical pixel, it must not be null and must be bigger than zero.

The first time a size is set triggers the creation of the Android view.

Returns the buffer size in logical pixel that backs the texture where the platform view pixels are written to.

The buffer size may or may not be the same as size.

As a result, consumers are expected to clip the texture using size, while using the return value to size the texture.

Implementation

Future<Size> setSize(Size size) async {
  assert(_state != _AndroidViewState.disposed, 'Android view is disposed. View id: $viewId');
  if (_state == _AndroidViewState.waitingForSize) {
    // Either `create` hasn't been called, or it couldn't run due to missing
    // size information, so create the view now.
    await create(size: size);
    return size;
  } else {
    return _sendResizeMessage(size);
  }
}