macOS fullscreen blocking content
When making the window full screen (green expand button), there seems to be a bar blocking content.
If I disable windows manager, the issue goes away.
Screenshots
Not Fullscreen:

Fullscreen:

Fullscreen on top hover:

Is there any example code? I think this is a macOS bug, what is your operating system environment?
Original issue: https://github.com/GroovinChip/macos_ui/issues/266
I can reproduce this issue with these steps:
- Add latest window_manager to pubpspec.yaml
- Replace
macos/Runner/MainFlutterWindow.swiftwith https://github.com/GroovinChip/macos_ui#modern-window-look - Initialize windowManager using
await windowManager.ensureInitialized();
Minimal main.dart code:
import 'package:flutter/cupertino.dart';
import 'package:window_manager/window_manager.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: 'Flutter Demo',
home: Text('test'),
);
}
}
The problem is, this line in the modified macos/Runner/MainFlutterWindow.swift
self.toolbar?.isVisible = false
It's supposed to hide to toolbar when going to fullscreen, but it isn't working as expected. It just doesn't do anything
Found a fix:
add these line to WindowManager.swift
public func windowWillEnterFullScreen(_ notification: Notification) {
mainWindow.toolbar?.isVisible = false
}
and this line
mainWindow.toolbar?.isVisible = true
after
public func windowDidExitFullScreen(_ notification: Notification){
Also, you can remove
func windowWillEnterFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = false
}
func windowDidExitFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = true
}
from macos/Runner/MainFlutterWindow.swift since it's useless as of now
Note that this is only a temporary fix for this specific use case and I'm not experienced enough in swift to make a pull request for this issue
@edeuss
@damywise may I ask you to make a fork and add this temporary fix to it?
It will help people who need to fix it right now :)
@Maksimka101 here you go window_manager_issue171
I guess another way to solve it is to implement new method like hideToolbar/showToolbar and simply calling them when window is entering/leaving full screen
https://github.com/alexmercerind/flutter_acrylic has a new feature:Window.addToolbar and Window.setToolbarStyle which should eliminate the need for this temporary fix.
https://github.com/alexmercerind/flutter_acrylic/issues/43
However, we also need to execute Window.removeToolbar() inside onWindowEnterFullScreen and Window.addToolbar() inside onWindowLeaveFullscreen
Note that currently, the function onWindowEnterFullScreen uses windowDidEnterFullScreen instead of windowWillEnterFullScreen, which is what I used in the temporary fix.
This makes the transition between normal and full screen not smooth since the empty toolbar will be shown for ~2 seconds (during the transition).
public func windowWillEnterFullScreen(_ notification: Notification) { mainWindow.toolbar?.isVisible = false }
@damywise It works for me but it causes the buttons to shift the the top corner:
Before:

After:

Oh yeah please don't do that anymore.
Use macos_window_utils instead
Please check https://github.com/leanflutter/window_manager/pull/319 if you are still affected by this.
You can test my proposed fix with this in your pubspec.yaml:
window_manager:
git:
url: https://github.com/cbenhagen/window_manager
ref: hide_toolbar
@cbenhagen Your proposed fix works for me, thanks a lot
@edeuss
Before:
How did you set this padding for traffic lights? Is this an old behavior of this framework? Trying to understand if I can get this with WindowManager or if I need something else.
(Right now I'm getting the version with the buttons glued to the corner).
@luizv You don't even need any plugin for that. You can modify the macos/Runner/MainFlutterWindow.swift file as mentioned here in the macos_uidocumentation: https://github.com/macosui/macos_ui#modern-window-look.
However, I recommend using the macos_window_utils package for most macOS window-related tasks because it allows for more programmatic control.
If macos_window_utils doesn't have the specific functionality you need, you can use window_manager as a complementary tool. That's what I do, at least.