mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Create flag to enable/disable FlutterView render surface conversion (#85648)
This commit is contained in:
parent
fecf2383de
commit
e82a69a95e
@ -179,6 +179,24 @@ class PlatformViewsService {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/// Whether the render surface of the Android `FlutterView` should be converted to a `FlutterImageView`.
|
||||
///
|
||||
/// When adding platform views using
|
||||
/// [Hybrid Composition](https://flutter.dev/docs/development/platform-integration/platform-views),
|
||||
/// the engine converts the render surface to a `FlutterImageView` to improve
|
||||
/// animation synchronization between Flutter widgets and the Android platform
|
||||
/// views. On Android versions < 10, this can have some performance issues.
|
||||
/// This flag allows disabling this conversion.
|
||||
///
|
||||
/// Defaults to true.
|
||||
static Future<void> synchronizeToNativeViewHierarchy(bool yes) {
|
||||
assert(defaultTargetPlatform == TargetPlatform.android);
|
||||
return SystemChannels.platform_views.invokeMethod<void>(
|
||||
'synchronizeToNativeViewHierarchy',
|
||||
yes,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(amirh): reference the iOS plugin API for registering a UIView factory once it lands.
|
||||
/// This is work in progress, not yet ready to be used, and requires a custom engine build. Creates a controller for a new iOS UIView.
|
||||
///
|
||||
|
||||
@ -141,6 +141,8 @@ class FakeAndroidPlatformViewsController {
|
||||
|
||||
int? lastClearedFocusViewId;
|
||||
|
||||
bool synchronizeToNativeViewHierarchy = true;
|
||||
|
||||
void registerViewType(String viewType) {
|
||||
_registeredViewTypes.add(viewType);
|
||||
}
|
||||
@ -166,6 +168,8 @@ class FakeAndroidPlatformViewsController {
|
||||
return _setDirection(call);
|
||||
case 'clearFocus':
|
||||
return _clearFocus(call);
|
||||
case 'synchronizeToNativeViewHierarchy':
|
||||
return _synchronizeToNativeViewHierarchy(call);
|
||||
}
|
||||
return Future<dynamic>.sync(() => null);
|
||||
}
|
||||
@ -299,6 +303,11 @@ class FakeAndroidPlatformViewsController {
|
||||
lastClearedFocusViewId = id;
|
||||
return Future<dynamic>.sync(() => null);
|
||||
}
|
||||
|
||||
Future<dynamic> _synchronizeToNativeViewHierarchy(MethodCall call) {
|
||||
synchronizeToNativeViewHierarchy = call.arguments as bool;
|
||||
return Future<dynamic>.sync(() => null);
|
||||
}
|
||||
}
|
||||
|
||||
class FakeIosPlatformViewsController {
|
||||
|
||||
@ -218,6 +218,11 @@ void main() {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
test('synchronizeToNativeViewHierarchy', () async {
|
||||
await PlatformViewsService.synchronizeToNativeViewHierarchy(false);
|
||||
expect(viewsController.synchronizeToNativeViewHierarchy, false);
|
||||
});
|
||||
});
|
||||
|
||||
group('iOS', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user