-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Hello the Flutter team. 🤗
I have several plugins for Flutter that embed a native view. Since updating to Flutter 3.7, the callbacks of views that inherit from PlatformView are no longer being called. On Android, these PlatformViews draw and return a SurfaceView. Looks like the view isn’t attached to the FlutterEngine, but I see the content of the first frame drawn in the AndroidSurfaceView widget.
Obviously, each view factories are registred in the method onAttachedToEngine of the entry class inheriting from FlutterPlugin.
Maybe I did something wrong but it's worked before the migration to Flutter 3.7.
I wrote a short example to reproduce this issue
Steps to Reproduce
- Execute
flutter runon the example project located here: draw_test.zip
Here is a screenshot, the green square with a circle are drawn on the kotlin side in a SurfaceView.
The class TestView below is in charge to draw this example.
class TestView(context: Context, id: Int, creationParams: Map<String?, Any?>?) : PlatformView {
...
override fun dispose() {
println("TestView: dispose")
}
override fun onFlutterViewAttached(flutterView: View) {
println("TestView: Flutter view attached!")
}
override fun onFlutterViewDetached() {
println("TestView: Flutter view detached.")
}
...Actual results: None of callbacks inherited from PlatformView are called. I see none of my debug lines in the console. Breakpoints never stop in functions onFlutterViewAttached, onFlutterViewDetached or dispose.
Expected results: PlatformView callbacks need to be called when the native view is added or removed from the widgets tree.
Details
flutter run --verbose :
the output is here: run.log
flutter doctor -v:
[√] Flutter (Channel stable, 3.7.1, on Microsoft Windows [version 10.0.19045.2486], locale fr-FR)
• Flutter version 3.7.1 on channel stable at C:\Dev\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7048ed95a5 (7 days ago), 2023-02-01 09:07:31 -0800
• Engine revision 800594f1f4
• Dart version 2.19.1
• DevTools version 2.20.1
[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\Dev\Android\SDK_Ext
• Platform android-33, build-tools 33.0.1
• ANDROID_HOME = C:\Dev\Android\SDK_Ext
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
• Visual Studio at D:\Dev\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.2.32630.192
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] Connected device (2 available)
• Mi 9T Pro (mobile) • 70ca026d • android-arm64 • Android 11 (API 30)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.19045.2486]
[√] HTTP Host Availability
• All required HTTP hosts are available
Thanks for your helps.
