@@ -779,7 +779,7 @@ abstract class AndroidViewController extends PlatformViewController {
779779 ///
780780 /// If [_createRequiresSize] is true, `size` is non-nullable, and the call
781781 /// should instead be deferred until the size is available.
782- Future <void > _sendCreateMessage ({required covariant Size ? size});
782+ Future <void > _sendCreateMessage ({required covariant Size ? size, Offset ? position });
783783
784784 /// Sends the message to resize the platform view to [size] .
785785 Future <Size > _sendResizeMessage (Size size);
@@ -788,7 +788,7 @@ abstract class AndroidViewController extends PlatformViewController {
788788 bool get awaitingCreation => _state == _AndroidViewState .waitingForSize;
789789
790790 @override
791- Future <void > create ({Size ? size}) async {
791+ Future <void > create ({Size ? size, Offset ? position }) async {
792792 assert (_state != _AndroidViewState .disposed, 'trying to create a disposed Android view' );
793793 assert (_state == _AndroidViewState .waitingForSize, 'Android view is already sized. View id: $viewId ' );
794794
@@ -798,7 +798,7 @@ abstract class AndroidViewController extends PlatformViewController {
798798 }
799799
800800 _state = _AndroidViewState .creating;
801- await _sendCreateMessage (size: size);
801+ await _sendCreateMessage (size: size, position : position );
802802 _state = _AndroidViewState .created;
803803
804804 for (final PlatformViewCreatedCallback callback in _platformViewCreatedCallbacks) {
@@ -1011,7 +1011,7 @@ class SurfaceAndroidViewController extends AndroidViewController {
10111011 bool get _createRequiresSize => true ;
10121012
10131013 @override
1014- Future <bool > _sendCreateMessage ({required Size size}) async {
1014+ Future <bool > _sendCreateMessage ({required Size size, Offset ? position }) async {
10151015 assert (! size.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.' );
10161016
10171017 final dynamic response = await _AndroidViewControllerInternals .sendCreateMessage (
@@ -1022,6 +1022,7 @@ class SurfaceAndroidViewController extends AndroidViewController {
10221022 layoutDirection: _layoutDirection,
10231023 creationParams: _creationParams,
10241024 size: size,
1025+ position: position,
10251026 );
10261027 if (response is int ) {
10271028 (_internals as _TextureAndroidViewControllerInternals ).textureId = response;
@@ -1076,13 +1077,14 @@ class ExpensiveAndroidViewController extends AndroidViewController {
10761077 bool get _createRequiresSize => false ;
10771078
10781079 @override
1079- Future <void > _sendCreateMessage ({required Size ? size}) async {
1080+ Future <void > _sendCreateMessage ({required Size ? size, Offset ? position }) async {
10801081 await _AndroidViewControllerInternals .sendCreateMessage (
10811082 viewId: viewId,
10821083 viewType: _viewType,
10831084 hybrid: true ,
10841085 layoutDirection: _layoutDirection,
10851086 creationParams: _creationParams,
1087+ position: position,
10861088 );
10871089 }
10881090
@@ -1133,7 +1135,7 @@ class TextureAndroidViewController extends AndroidViewController {
11331135 bool get _createRequiresSize => true ;
11341136
11351137 @override
1136- Future <void > _sendCreateMessage ({required Size size}) async {
1138+ Future <void > _sendCreateMessage ({required Size size, Offset ? position }) async {
11371139 assert (! size.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.' );
11381140
11391141 _internals.textureId = await _AndroidViewControllerInternals .sendCreateMessage (
@@ -1143,6 +1145,7 @@ class TextureAndroidViewController extends AndroidViewController {
11431145 layoutDirection: _layoutDirection,
11441146 creationParams: _creationParams,
11451147 size: size,
1148+ position: position,
11461149 ) as int ;
11471150 }
11481151
@@ -1190,7 +1193,8 @@ abstract class _AndroidViewControllerInternals {
11901193 required bool hybrid,
11911194 bool hybridFallback = false ,
11921195 _CreationParams ? creationParams,
1193- Size ? size}) {
1196+ Size ? size,
1197+ Offset ? position}) {
11941198 final Map <String , dynamic > args = < String , dynamic > {
11951199 'id' : viewId,
11961200 'viewType' : viewType,
@@ -1199,6 +1203,8 @@ abstract class _AndroidViewControllerInternals {
11991203 if (size != null ) 'width' : size.width,
12001204 if (size != null ) 'height' : size.height,
12011205 if (hybridFallback == true ) 'hybridFallback' : hybridFallback,
1206+ if (position != null ) 'left' : position.dx,
1207+ if (position != null ) 'top' : position.dy,
12021208 };
12031209 if (creationParams != null ) {
12041210 final ByteData paramsByteData = creationParams.codec.encodeMessage (creationParams.data)! ;
@@ -1449,7 +1455,11 @@ abstract class PlatformViewController {
14491455 /// [size] is the view's initial size in logical pixel.
14501456 /// [size] can be omitted if the concrete implementation doesn't require an initial size
14511457 /// to create the platform view.
1452- Future <void > create ({Size ? size}) async {}
1458+ ///
1459+ /// [position] is the view's initial position in logical pixels.
1460+ /// [position] can be omitted if the concrete implementation doesn't require
1461+ /// an initial position.
1462+ Future <void > create ({Size ? size, Offset ? position}) async {}
14531463
14541464 /// Disposes the platform view.
14551465 ///
0 commit comments