Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inlining Android/iOS views #19030

Closed
amirh opened this issue Jul 3, 2018 · 57 comments

Comments

@amirh
Copy link
Contributor

commented Jul 3, 2018

A generic solution for embedding any Android/iOS view as part of the Flutter widget hierarchy would enable some highly desired features including Google Maps (#73) and WebView (#730).

@rolurq

This comment has been minimized.

Copy link

commented Jul 9, 2018

Also on this matter, this would be useful when embedding camera stream in an application.

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 9, 2018

For a camera stream you probably want to use a Texture widget directly.
The camera plugin is doing that for the device's cameras: https://pub.dartlang.org/packages/camera

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 11, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to amirh/engine that referenced this issue Jul 13, 2018

Implement PlatformViewsController.
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030

amirh added a commit to flutter/engine that referenced this issue Jul 13, 2018

Implement PlatformViewsController. (#5722)
Each platform view created (by a plugin supplied factory) is attached to
a virtual display.
The virtual displays are controlled by VirtualDisplayController objects.
The PlatformViewsController maintains a mapping from a platform view's
id to its VirtualDisplayController, which allows it to operate on the
virtual display for a given platform view ID when asked so over the
method channel.

This is using API level 20 APIs, on lower API levels all platform views
method channel calls are noops.
We can make this work on API 19 with some refactoring to the
TextureRegistry (allow the engine Java code to recycle a texture entry
id).

This CL also adds a platform view id parameter to the
PlatformViewFactory#create() method. This allows plugins to route
platform channel messages to specific instances of a platform view.

TBD in future CLs:
  * Forward touch events to the platform views.
  * Support accessibility for platform views.

flutter/flutter#19030
@benbucksch

This comment has been minimized.

Copy link

commented Jul 20, 2018

Do you guys need help here, in development?

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 20, 2018

@benbucksch contributions are welcomed, here are 2 issues you can look at: #19417 #19418.

Thanks!

@yohom

This comment has been minimized.

Copy link

commented Jul 28, 2018

So far I've only found AndroidView, is there an IOSView? Thanks. @amirh

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2018

@yohom this is still work in progress, I started with the Android support.
I wouldn't even use AndroidView yet as it is incomplete and unstable.

@morad00

This comment has been minimized.

Copy link

commented Jul 31, 2018

Looks good! hope much support from flutter team

@newbie-gk

This comment has been minimized.

Copy link

commented Aug 9, 2018

Would absolutely love this feature :)
Any plans on when will this be available?

@tiagofalves

This comment has been minimized.

Copy link

commented Aug 9, 2018

Hi @amirh, first of all, a big thank you. If you need help with testing the features i can help.

@Hixie Hixie added this to the bucket10 milestone Aug 21, 2018

@zerox1212

This comment has been minimized.

Copy link

commented Nov 6, 2018

Looking forward to cross platform map support. I really need it for the conversion of my map based app from native to flutter. Thanks for the work!

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Nov 10, 2018

iOS view embedding support has landed on master.

This is still just a preview.

There are multiple open issues for missing features, bugs, and potential optimizations, the relevant issues are tagged with the platform-views label. Please upvote the ones you care about to help us prioritize.

Notably on iOS embedding UIViews currently requires running Flutter with a single thread, as the required threading configuration is not yet supported (we are working on it: #23974, #23975).

Currently apps need to opt-in for the UIViews embedding preview on iOS by adding a boolean property to the Info.plist (key=io.flutter.embedded_views_preview value=YES).

Documentation is still a little light, for a simple usage example you can check flutter/plugins#890 which adds iOS support to the webview_flutter plugin.

@sreekanth-krishnan

This comment has been minimized.

Copy link

commented Nov 24, 2018

How do I include this in my project now? I guess the pub dependency is not available yet.

@mclark4386

This comment has been minimized.

Copy link

commented Nov 24, 2018

@yoavrofe

This comment has been minimized.

Copy link

commented Nov 29, 2018

@amirh, please note the bug on Android devices with a notch, which currently prevents using platform view in production.

@MarcAlx

This comment has been minimized.

Copy link

commented Feb 11, 2019

iOS view embedding support has landed on master.

This is still just a preview.

There are multiple open issues for missing features, bugs, and potential optimizations, the relevant issues are tagged with the platform-views label. Please upvote the ones you care about to help us prioritize.

Notably on iOS embedding UIViews currently requires running Flutter with a single thread, as the required threading configuration is not yet supported (we are working on it: #23974, #23975).

Currently apps need to opt-in for the UIViews embedding preview on iOS by adding a boolean property to the Info.plist (key=io.flutter.embedded_views_preview value=YES).

Documentation is still a little light, for a simple usage example you can check flutter/plugins#890 which adds iOS support to the webview_flutter plugin.

Here's how to achieve the above solution :

Add the following lines to <root of your project>/ios/Runner/Info.plist

<dict>
     ...
    <key>io.flutter.embedded_views_preview</key>
    <true/>
    ....
</dict>
@WChoy

This comment has been minimized.

Copy link

commented Feb 25, 2019

Need to correct README.md

If you use Xcode, the "Custom iOS Target Properties" , the value is a Boolean "Yes",

io flutter embedded_views_preview

this will result in what MarcAlx said "".... not "" (as in the Boring Show).

<dict> ... <key>io.flutter.embedded_views_preview</key> <true/> .... </dict>

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2019

@WChoy I'm not sure which README.md you refer to, can you link the specific file?

@mduenas

This comment has been minimized.

Copy link

commented Mar 2, 2019

This works for iOS using flutter_google_map, but every so often I'm using the app and the screen render goes totally fuzzy. All graphics and text (on all widgets) are distorted and not visually discernable...Any thoughts on why this would be happening?

@amirh

This comment has been minimized.

Copy link
Contributor Author

commented Mar 3, 2019

@mduenas does #27561 sounds like the same issue you're hitting?

@smj992925133

This comment has been minimized.

Copy link

commented Mar 28, 2019

Need to correct README.md

If you use Xcode, the "Custom iOS Target Properties" , the value is a Boolean "Yes",

io flutter embedded_views_preview

this will result in what MarcAlx said "".... not "" (as in the Boring Show).

<dict> ... <key>io.flutter.embedded_views_preview</key> <true/> .... </dict>

因地图在ios上不显示,所以加入了在info.plist加入 io.flutter.embedded_views_preview
这个,地图显示了,但我的入口页面出现花屏了,之前不加的时候没有问题,
请问,怎么解决

@mduenas

This comment has been minimized.

Copy link

commented Mar 28, 2019

@mduenas does #27561 sounds like the same issue you're hitting?

Yes, that is how my screen renders as well.

@lililixiaofei

This comment has been minimized.

Copy link

commented Jun 12, 2019

Need to correct README.md
If you use Xcode, the "Custom iOS Target Properties" , the value is a Boolean "Yes",
io flutter embedded_views_preview
this will result in what MarcAlx said "".... not "" (as in the Boring Show).
<dict> ... <key>io.flutter.embedded_views_preview</key> <true/> .... </dict>

因地图在ios上不显示,所以加入了在info.plist加入 io.flutter.embedded_views_preview
这个,地图显示了,但我的入口页面出现花屏了,之前不加的时候没有问题,
请问,怎么解决

遇到了同样的问题,请问解决了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.