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 · 64 comments
Closed

Support inlining Android/iOS views #19030

amirh opened this issue Jul 3, 2018 · 64 comments
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: new feature Nothing broken; request for a new capability

Comments

@amirh
Copy link
Contributor

amirh 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
Copy link

rolurq commented Jul 9, 2018

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

@amirh
Copy link
Contributor Author

amirh 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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 11, 2018
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 pushed a commit to amirh/engine that referenced this issue Jul 13, 2018
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
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
Copy link

Do you guys need help here, in development?

@amirh amirh added the a: platform-views Embedding Android/iOS views in Flutter apps label Jul 20, 2018
@amirh
Copy link
Contributor Author

amirh commented Jul 20, 2018

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

Thanks!

@yohom
Copy link

yohom commented Jul 28, 2018

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

@amirh
Copy link
Contributor Author

amirh 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
Copy link

morad00 commented Jul 31, 2018

Looks good! hope much support from flutter team

@newbie-gk
Copy link

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

@tiagofalves
Copy link

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
@amirh
Copy link
Contributor Author

amirh 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
Copy link

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

@mclark4386
Copy link

Is this it? https://github.com/ibhavikmakwana/flutter_google_map

@yoavrofe
Copy link

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

@MarcAlx
Copy link

MarcAlx 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
Copy link

WChoy 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
Copy link
Contributor Author

amirh commented Feb 25, 2019

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

@mduenas
Copy link

mduenas 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
Copy link
Contributor Author

amirh commented Mar 3, 2019

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

@smj992925133
Copy link

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
Copy link

mduenas 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
Copy link

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
这个,地图显示了,但我的入口页面出现花屏了,之前不加的时候没有问题,
请问,怎么解决

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

@lukepighetti
Copy link

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

Since the map is not displayed on ios, I joined io.flutter.embedded_views_preview in info.plist
This, the map is displayed, but my entry page has a screen, and there is no problem when I didn’t add it before.
Excuse me, how to solve it

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

I have encountered the same problem. Is it solved?

@bemesquita
Copy link

Added the io.flutter.embedded_views_preview on my info.plist and still getting the error =/

@xj5513
Copy link

xj5513 commented Dec 21, 2019

io.flutter.embedded_views_preview
YES

@cip22
Copy link

cip22 commented Jan 13, 2020

I had the error message "Trying to embed a platform view but the PrerollContext does not support embedding" with the qr_code_scanner package on iOS and it was solved with io.flutter.embedded_views_preview = YES in my info.plist file.

@Alexakis97
Copy link

Alexakis97 commented Dec 13, 2020

Guys tried minSdkVersion 29 and put the key in Info.plist nothing seems to work for me

That's the exception:

E/flutter (12880): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, java.lang.IllegalStateException: Trying to create a platform view of unregistered type: plugins.flutter.io/webview

@lukepighetti
Copy link

That looks like a good question for Stack Overflow!

@github-actions
Copy link

github-actions bot commented Aug 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: new feature Nothing broken; request for a new capability
Projects
None yet
Development

No branches or pull requests