Always use texture layer when displaying an Android view#100091
Always use texture layer when displaying an Android view#100091fluttergithubbot merged 13 commits intoflutter:masterfrom
Conversation
| /// * [AndroidView] which is a widget that is used to show an Android view. | ||
| /// * [PlatformViewsService] which is a service for controlling platform views. | ||
| class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin { | ||
| class RenderAndroidView extends PlatformViewRenderBox { |
There was a problem hiding this comment.
Making RenderAndroidView extend PlatformViewRenderBox allows AndroidViewSurface to continue to extend PlatformViewSurface due to the updateRenderObject override.
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = viewController; | ||
| viewController.addOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| viewController.pointTransformer = (Offset offset) => globalToLocal(offset); |
There was a problem hiding this comment.
This seems to be bug currently. pointTransformer is set in the controller during initialization, but it's not set again if the controller is changed.
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = viewController; |
There was a problem hiding this comment.
this calls the setter in the parent class. I don't like this API, but I'm trying to make this PR a non-breaking change.
| _viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); |
There was a problem hiding this comment.
Is (controller as AndroidViewController) just the getter viewController? (Not the parameter)
There was a problem hiding this comment.
I cleaned this up. I removed viewController and overrode controller.
| /// Sets a new Android view controller. | ||
| /// | ||
| /// `viewController` must not be null. | ||
| set viewController(AndroidViewController viewController) { |
There was a problem hiding this comment.
Prob better name this paramter so it doesn't conflict with the getter viewController
There was a problem hiding this comment.
I removed viewController and overrode controller instead.
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| controller = viewController; | ||
| viewController.addOnPlatformViewCreatedListener(_onPlatformViewCreated); |
There was a problem hiding this comment.
It looks a little confusing changing the property after sets the ivar. How about:
this. viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated);
controller = viewController
controller.addOnPlatformViewCreatedListener(_onPlatformViewCreated);
controller.pointTransformer = (Offset offset) => globalToLocal(offset);
...
| @override | ||
| Future<void> _sendCreateMessage() async { | ||
| assert(!_initialSize.isEmpty, 'trying to create $TextureAndroidViewController without setting a valid size.'); | ||
| assert(_initialSize != null, 'trying to create $TextureAndroidViewController without setting an initial size.'); |
There was a problem hiding this comment.
can we test these 2 asserts?
There was a problem hiding this comment.
Done. This is guarded by the create() method, which doesn't call super.create unless _initialSize is set. These are tested in services/platform_views_test.dart.
| _viewController.removeOnPlatformViewCreatedListener(_onPlatformViewCreated); | ||
| _viewController = viewController; | ||
|
|
||
| (controller as AndroidViewController).removeOnPlatformViewCreatedListener(_onPlatformViewCreated); |
There was a problem hiding this comment.
can this be tested? e.g. the listener is removed from the old controller. and added to the new controller
…iew (flutter#100091)" (flutter#100222)" This reverts commit 1c2c942.
Ensures that Android views are always rendered using a texture layer.
Related issue: #96679