setSize method Null safety
- Size size
override
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
@override
Future<Size> setSize(Size size) async {
assert(_state != _AndroidViewState.disposed, 'Android view is disposed. View id: $viewId');
assert(_state != _AndroidViewState.waitingForSize, 'Android view must have an initial size. View id: $viewId');
assert(size != null);
assert(!size.isEmpty);
final Map<Object?, Object?>? meta = await SystemChannels.platform_views.invokeMapMethod<Object?, Object?>(
'resize',
<String, dynamic>{
'id': viewId,
'width': size.width,
'height': size.height,
},
);
assert(meta != null);
assert(meta!.containsKey('width'));
assert(meta!.containsKey('height'));
return Size(meta!['width']! as double, meta['height']! as double);
}