Closed moazelshebly closed 3 years ago
The window_size
plugin has never had that functionality; any restoration behavior you saw previously was entirely controlled by the OS.
Given that it's relatively straightforward to implement that logic in Dart using existing window_size
functionality and something like shared_preferences
, I don't plan to implement auto-save in this temporary plugin. (It's certainly something that would be reasonable to build into the eventual Flutter framework support for window management.)
@stuartmorgan Sorry for bothering you again, but this feature that an application window restores it's dimensions and position from a previous session is common on Windows and macOS and the absence of it makes Flutter application feel less native on desktop. I think it is worth considering whether this should be implemented as a default behaviour.
As you have stated it is trivial to implement such behaviour thanks to the great window_size
and shared_preferences
plugins, but I am having difficulties figuring out when and where to hook into a "application window closed" event to read and persist the dimensions and position somewhere.
Can you give a hint where this could be done? Maybe somewhere in Dart, in the runner application or as part of the engine?
I think it is worth considering whether this should be implemented as a default behaviour.
I specifically said I thought it likely should be. Just not in a temporary plugin; the goal of window_size
is not for it to do everything someone might want to do, it's to address some very high-priority gaps in the short term.
If someone really wants autosave behavior prior to Flutter itself having window management APIs, they could certainly implement their own plugin to do so; there's no reason it needs to be part of this plugin. The overlap between the existing window_size
code and such a plugin would be nil, since it would all happen on the native side, using standard platform APIs.
I am having difficulties figuring out when and where to hook into a "application window closed" event to read and persist the dimensions and position somewhere.
Can you give a hint where this could be done? Maybe somewhere in Dart, in the runner application or as part of the engine?
There's currently no hook for that in Dart; there's an open feature request for it in flutter/flutter. But you can check the window size on every build, and persist it if it's changed, rather than using a window close hook.
(If you really want to add a window close hook locally, you could do so in your runner, using platform channels; you'd need to look into window close delegation for each of the native platforms, and then add a method channel to coordinate with your Dart code. And if you want to add that functionality to Flutter, it would be implemented in each embedding, with communication over a system channel. Both are doable, but non-trivial.)
Describe the bug It seems that since macOS Big Sur came out, the window dimensions and position of the last app session are not saved anymore. This leads to the app being launched every time in the same position and same dimension that are set in the app and not the ones that the user set during their last use of the app.
It used to work on macOS Catalina but now it is not anymore.
Doctor Output