@@ -779,7 +779,7 @@ abstract class AndroidViewController extends PlatformViewController {
779
779
///
780
780
/// If [_createRequiresSize] is true, `size` is non-nullable, and the call
781
781
/// 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 });
783
783
784
784
/// Sends the message to resize the platform view to [size] .
785
785
Future <Size > _sendResizeMessage (Size size);
@@ -788,7 +788,7 @@ abstract class AndroidViewController extends PlatformViewController {
788
788
bool get awaitingCreation => _state == _AndroidViewState .waitingForSize;
789
789
790
790
@override
791
- Future <void > create ({Size ? size}) async {
791
+ Future <void > create ({Size ? size, Offset ? position }) async {
792
792
assert (_state != _AndroidViewState .disposed, 'trying to create a disposed Android view' );
793
793
assert (_state == _AndroidViewState .waitingForSize, 'Android view is already sized. View id: $viewId ' );
794
794
@@ -798,7 +798,7 @@ abstract class AndroidViewController extends PlatformViewController {
798
798
}
799
799
800
800
_state = _AndroidViewState .creating;
801
- await _sendCreateMessage (size: size);
801
+ await _sendCreateMessage (size: size, position : position );
802
802
_state = _AndroidViewState .created;
803
803
804
804
for (final PlatformViewCreatedCallback callback in _platformViewCreatedCallbacks) {
@@ -1011,7 +1011,7 @@ class SurfaceAndroidViewController extends AndroidViewController {
1011
1011
bool get _createRequiresSize => true ;
1012
1012
1013
1013
@override
1014
- Future <bool > _sendCreateMessage ({required Size size}) async {
1014
+ Future <bool > _sendCreateMessage ({required Size size, Offset ? position }) async {
1015
1015
assert (! size.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.' );
1016
1016
1017
1017
final dynamic response = await _AndroidViewControllerInternals .sendCreateMessage (
@@ -1022,6 +1022,7 @@ class SurfaceAndroidViewController extends AndroidViewController {
1022
1022
layoutDirection: _layoutDirection,
1023
1023
creationParams: _creationParams,
1024
1024
size: size,
1025
+ position: position,
1025
1026
);
1026
1027
if (response is int ) {
1027
1028
(_internals as _TextureAndroidViewControllerInternals ).textureId = response;
@@ -1076,13 +1077,14 @@ class ExpensiveAndroidViewController extends AndroidViewController {
1076
1077
bool get _createRequiresSize => false ;
1077
1078
1078
1079
@override
1079
- Future <void > _sendCreateMessage ({required Size ? size}) async {
1080
+ Future <void > _sendCreateMessage ({required Size ? size, Offset ? position }) async {
1080
1081
await _AndroidViewControllerInternals .sendCreateMessage (
1081
1082
viewId: viewId,
1082
1083
viewType: _viewType,
1083
1084
hybrid: true ,
1084
1085
layoutDirection: _layoutDirection,
1085
1086
creationParams: _creationParams,
1087
+ position: position,
1086
1088
);
1087
1089
}
1088
1090
@@ -1133,7 +1135,7 @@ class TextureAndroidViewController extends AndroidViewController {
1133
1135
bool get _createRequiresSize => true ;
1134
1136
1135
1137
@override
1136
- Future <void > _sendCreateMessage ({required Size size}) async {
1138
+ Future <void > _sendCreateMessage ({required Size size, Offset ? position }) async {
1137
1139
assert (! size.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.' );
1138
1140
1139
1141
_internals.textureId = await _AndroidViewControllerInternals .sendCreateMessage (
@@ -1143,6 +1145,7 @@ class TextureAndroidViewController extends AndroidViewController {
1143
1145
layoutDirection: _layoutDirection,
1144
1146
creationParams: _creationParams,
1145
1147
size: size,
1148
+ position: position,
1146
1149
) as int ;
1147
1150
}
1148
1151
@@ -1190,7 +1193,8 @@ abstract class _AndroidViewControllerInternals {
1190
1193
required bool hybrid,
1191
1194
bool hybridFallback = false ,
1192
1195
_CreationParams ? creationParams,
1193
- Size ? size}) {
1196
+ Size ? size,
1197
+ Offset ? position}) {
1194
1198
final Map <String , dynamic > args = < String , dynamic > {
1195
1199
'id' : viewId,
1196
1200
'viewType' : viewType,
@@ -1199,6 +1203,8 @@ abstract class _AndroidViewControllerInternals {
1199
1203
if (size != null ) 'width' : size.width,
1200
1204
if (size != null ) 'height' : size.height,
1201
1205
if (hybridFallback == true ) 'hybridFallback' : hybridFallback,
1206
+ if (position != null ) 'left' : position.dx,
1207
+ if (position != null ) 'top' : position.dy,
1202
1208
};
1203
1209
if (creationParams != null ) {
1204
1210
final ByteData paramsByteData = creationParams.codec.encodeMessage (creationParams.data)! ;
@@ -1449,7 +1455,11 @@ abstract class PlatformViewController {
1449
1455
/// [size] is the view's initial size in logical pixel.
1450
1456
/// [size] can be omitted if the concrete implementation doesn't require an initial size
1451
1457
/// 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 {}
1453
1463
1454
1464
/// Disposes the platform view.
1455
1465
///
0 commit comments