Canonical: Bringing multiple windows to Flutter desktop apps

7 Likes

Unfortunately the don’t descibe how they achive the multi window. does each run its own build loop in a separate isolate?

Everything is public tho.

1 Like

No, it uses a single widget tree in a single isolate. Canonical’s design builds on the multi-view feature: Multiple Views (PUBLICLY SHARED) - Google Docs

3 Likes

One year later, updates?

1 Like

Seems like it’s a bit more complex problem, adding this to the engine, the way they want, I can’t find any updates from them.

Theoretically, if you don’t care about pop-ups being in a separate window, you could achieve multi window, with some external wiring. A launcher script that launches new instances of the app with some launch arguments passed to the app, saving the necessary state information in some database/file and watching for changes in this database/file.

I never tried this just thought about it. File based approach should be enough. When you want to launch a new window, you write the parameters for the new window in a file, the launcher script(this can be dart too) watches for file changes and starts another instance if requested. You also write necessary global state information to file, so the other instance can update itself based on this file.

Or do some inter process communication, but idk how reliable or simple is that. I saw a few programs sharing information between instances through files, they work well and simple to understand/debug. If you don’t update the files often and only update them under some conditions, you can prevent the two or more instances making conflicting writes.

Idk why Canonical didn’t do something like this, Gnome doesn’t have separate popup windows from the parent window either. This doesn’t require engine modifications, this could be a package.

edit: Looks like this does multi window, the launching looks simple, not sure what happens if you close the main window desktop_multi_window | Flutter package

It works. Try the example flutter/examples/multiple_windows at master · flutter/flutter · GitHub

I’ve migrated my app Keystro to Flutter-native multi windows.
Unlike desktop_multi_window, it only spawns one Flutter engine for all windows, which makes it lighter.
Instead of one engine per window.

2 Likes

When it was released? I couldn’t hear the fanfare that a proper Desktop support should cause. Where is the documentation?

the description says only windows is supported

Dumb question:

Flutter engine is tied to a window at all times? It wouldn’t be possible to do as WPF does: Application doesn’t have any view capabilities, but spawns a Window set as startup window. Then, when a new Window is created, you can set newWindow.owner = this; to tell who owns what (basically creating a hierarchy of windows tracing back to the main window).

It would be nice if Flutter had something like WPF Application class: a main entrypoint that have no visual rendering, but only config.

I think this is really important, especially because of DEX/Android 16 app-mode (or whatever that is called). (not sure if DEX supports multiwindow for the same app).

So still WIP, like 7 years ago, in 2019, when presented as tech preview (feature incomplete and unstable). Now less feature incomplete and less unstable.

The chosen design being implemented since 2020 (6 years ago) is the following:

And views 3 years ago:

Works for Linux and MacOS as well.
My app is Windows and MacOS.