I'm investigating integrating Flutter into existing iOS and Android projects. My main experience is in iOS, so this post will be from an iOS perspective. But feel free to substitute UIViewController for Activity/Fragment. I'll give some background on my current understanding, and will have my actual questions at the end of the post.
Our main use case is to embed small Widget
s into existing view controllers. I've gone through the Flutter docs and guides and have successfully integrated with our project (it was actually pretty easy!) but have concerns with Flutter's overall design being incompatible with our desired usage.
It seems that Flutter would ideally like to be the entire UI for an application: create and start an engine on app launch, pass the engine to a FlutterView, and make that the root view for the app. Alternatively, Flutter seems happy to own whole flows in the app where you push a fullscreen Widget
which does some work, maybe pushes/pops more screens, and eventually returns control back to the native app.
However, in the case where I have a native screen with some UI components where I want to also have a flutter Widget
which displays some other data - eg a bar graph - it seems that I need to either create separate modules, or separate @pragma(vm:entry-point)
functions in my Flutter project for each type of Widget
(graph, in this case) that I'd like to display.
My understanding is that each of these Widget
s would also need their own Flutter engine instance which loads the proper entry point/route to that Widget
's main
function which then calls runApp(MyWidget)
.
So on to my actual questions:
Widget
s in view controllers?Widget
s that are embedded into a view controller, I'll need to create separate engine isolates for each one?I'm still wrapping my head around Flutter, but I've been impressed with its capabilities so far! Please let me know if I'm missing something here.
For anyone coming across this in the future, as of Oct. 21, 2020, the use case of embedding multiple Flutter widgets inside of a native UIViewController is not encouraged. Doing this in a performant manner requires updates to Flutter to better share memory and threads across engine instances.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.