Open kerberjg opened 1 month ago
macos_window_utils provides a TitlebarSafeArea class specifically for this purpose.
@Adrian-Samoticha That does not yield the intended result.
return TitlebarSafeArea(
child: app
);
In Flutter, SafeArea
is used to wrap the content of a page, not the page scaffold itself.
If the MediaQueryData.padding
property had been set properly, there wouldn't be a need for a separate TitlebarSafeArea
widget, as the vanilla SafeArea
widget pulls information from MediaQueryData.padding
, as do the various AppBar widgets in all design libraries.
The ideal solution would be something like WindowManipulator.getMediaQueryData
that will return the MediaQueryData object with the proper padding
(and other properties, as needed) set, in addition to documentation so users know when/how to use it.
I'd be happy to contribute any of the above improvements if they sound good
If the TitlebarSafeArea
doesn’t fit your use case and you’d like to construct a MediaQueryData
with the appropriate padding, you can use the WindowManipulator.getTitlebarHeight()
method to get the height of the title bar.
That is what I'm currently doing, however I was suggesting that perhaps this is functionality that the library should provide out-of-the-box, since without it most Cupertino/Material apps will look & behave improperly
I don’t really think that’s necessary. Since macos_window_utils provides only a single property that’s in any way related to MediaQuery
, it wouldn’t really make much sense to abstract that away. Also, if you’re trying to create an app that looks like a native macOS app, you should probably check out macos_ui instead of using Flutter’s built-in Cupertino widgets.
When using
macos_window_utils
in combination with other UI libraries like Material and Cupertino, the content tends to invade the button area, like this:The simple solution would be to set the
viewPadding
property on MediaQuery, which is how Flutter compensates for notches on phones. Here's my temporary workaround:Works as intended: