Commit 0057dc63 authored by hym's avatar hym

fix platformview bug

parent fc847037
...@@ -448,6 +448,9 @@ public class XFlutterView extends FrameLayout { ...@@ -448,6 +448,9 @@ public class XFlutterView extends FrameLayout {
this.flutterEngine = flutterEngine; this.flutterEngine = flutterEngine;
// initialize PlatformViewsController
this.flutterEngine.getPluginRegistry().getPlatformViewsController().attach(getContext(),flutterEngine.getRenderer(),flutterEngine.getDartExecutor());
// Instruct our FlutterRenderer that we are now its designated RenderSurface. // Instruct our FlutterRenderer that we are now its designated RenderSurface.
this.flutterEngine.getRenderer().attachToRenderSurface(renderSurface); this.flutterEngine.getRenderer().attachToRenderSurface(renderSurface);
...@@ -506,6 +509,10 @@ public class XFlutterView extends FrameLayout { ...@@ -506,6 +509,10 @@ public class XFlutterView extends FrameLayout {
} }
Log.d(TAG, "Detaching from Flutter Engine"); Log.d(TAG, "Detaching from Flutter Engine");
// detach platformviews in page in case memory leak
flutterEngine.getPluginRegistry().getPlatformViewsController().detach();
flutterEngine.getPluginRegistry().getPlatformViewsController().onFlutterViewDestroyed();
// Inform the Android framework that it should retrieve a new InputConnection // Inform the Android framework that it should retrieve a new InputConnection
// now that the engine is detached. The new InputConnection will be null, which // now that the engine is detached. The new InputConnection will be null, which
// signifies that this View does not process input (until a new engine is attached). // signifies that this View does not process input (until a new engine is attached).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment