Native surface or shared texture widget - Windows

I’m interested in using Flutter for an application that needs to run on Windows (MacOS will be required but not initially). A hard requirement is that content rendered with Vulkan (viewport/texture) is displayed within the application alongside and underneath UI elements.

After a bit of research it is unclear to me if there is a straightforward way to achieve this with Flutter/Dart. I did find some documentation in the Windows API but I think it may be out of date - it links to Flutter Windows Embedder which seems to be for a discontinued repository.

Looking into the native Windows code I see that it could be possibly hacked in to create my own HWND but that wouldn’t be ideal…

I also noted that there is a Vulkan bindings package available for Dart but it doesn’t seem to be relevant to Flutter (the example just opens a GLFW window) - in either case I would need to use FFI with existing Vulkan code for this application (which I can update to interface with Dart).

I’m just not seeing a clear path to either sharing a texture (with Skia I presume on windows) or get a HWND to a child window managed by Flutter.

Any thoughts or precedent relating to this?

2 Likes

Could you share a link to this outdated documentation? We should update that.

You can pass external textures to Flutter Windows using the TextureRegistrar, which you can get using PluginRegistrar::texture_registrar.

You can get the HWND to the child window managed by Flutter using FlutterView::GetNativeWindow. You can get the FlutterView using FlutterViewController::view.

I’d take a look at the webview_windows package for prior art on external textures in Flutter Windows.

Please let me know if you have follow-up questions!

2 Likes

Thanks for the quick reply, this is really great news!

I might have been mistaken, I just doubled checked and when I went to the Flutter Windows Embedder API docs page I did a Google search looking for a guide and found this repository/readme. Sounds like the Flutter Windows Embedder is part of the main repository at this point.

Sounds like this along with webview_windows reference is exactly what I would need.

Thank you!

3 Likes