Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't set MediaQueryData.viewPadding #50

Open
kerberjg opened this issue Jul 31, 2024 · 5 comments
Open

Doesn't set MediaQueryData.viewPadding #50

kerberjg opened this issue Jul 31, 2024 · 5 comments

Comments

@kerberjg
Copy link

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:

image

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:

if(defaultTargetPlatform == TargetPlatform.macOS) {
      return MediaQuery(
        child: app,
        data: MediaQuery.of(context).copyWith(
          padding: const EdgeInsets.only(top: 40),
        ),
      );
    }

Works as intended:

image

@Adrian-Samoticha
Copy link
Member

macos_window_utils provides a TitlebarSafeArea class specifically for this purpose.

@kerberjg
Copy link
Author

kerberjg commented Aug 4, 2024

@Adrian-Samoticha That does not yield the intended result.

return TitlebarSafeArea(
  child: app
);
image

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

@Adrian-Samoticha
Copy link
Member

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.

@kerberjg
Copy link
Author

kerberjg commented Aug 5, 2024

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

@Adrian-Samoticha
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants