Repository: flutter
Issue: View external flutter project's UI inside an independent flutter project
Labels: framework,f: inspector,c: proposal,P3,team-framework,triaged-framework

## Use case

I am creating a desktop flutter app. It is a type of editor, and I would like to enable external developers to be able to create custom flutter UI's within certain portions of my flutter application. Essentially, I would like to embed their view inside of mine (without knowing at compile time). As far as I have researched, this is not directly possible since dart doesn't support dynamic linking/loading of external code. I don't need (or want) their code to handle anything backend, it's purely about finding a way to take build functions and display them in a separate flutter project (without knowing them at compile time).

I have thought of 2 workarounds that just aren't great.
First, parsing and rebuilding their widget structure from scratch (something like https://pub.dev/packages/dynamic_widget). Only it would need to handle a lot more widgets (basically all of them). The main downside I see with this is performance, but even more important is that it wouldn't look quite the same, since some code wouldn't be seen. For example, if they called and used `MediaQuery.of(context).size`, this wouldn't show up in the embedded view since it only knows about the widget structure. So this would work for simple projects but is quite limited.

Second, compiling their project (eg `flutter run`) in a process, and then calling the built project (in a process/isolate) which would display their project. The problem here is that it spawns their code in a completely new window. I am wondering if it is possible to embed their view somehow in another. The parent and child flutter views don't need to share (and actually shouldn't) backend code, but just need to be able to talk through isolates, which isn't a problem with this setup. However, I don't think there is currently a way to combine their views. My research into this brought me to https://github.com/flutter/flutter/issues/30701, but I'm not sure if, even when complete, this would fix my issue since that is all about separating windows not combining them.

I've had a couple of other ideas for workarounds like compiling the user's code to HTML (flutter web) and then running that using [flutter_html](https://pub.dev/packages/flutter_html). But I don't love this for performance, project consistency, and support (flutter web is still in early days). Another thing that caught my eye was the ability to create PlatformViews, but it seems that these are still known at compile time.

## Proposal

Functionally, I would like to be able to load/run/view an independent flutter project's UI within the view of a running flutter project (only for desktop).

I would be very willing and happy if there was some way for me to implement this myself, or create a pub package for it, but I don't know it's this is even possible beyond the workarounds I mentioned above. I don't imagine this is/would be very high of a priority for the flutter team in general, but am looking to see if there is some implementation or idea I don't know about that would make for a more complete solution that I can somehow implement, whether that be by flutter, c++ ffi somehow, etc.

Thanks!