window_manager
window_manager copied to clipboard
[Windows] Fix `flutter_acrylic` compatibility
Alright I've been kind of trying to fix this issue. Here's what I found:
-
WindowEffect.transparentis compatible, no issues there. -
TitleBarStyle.hiddenis NOT compatible withWindowEffect.mica,WindowEffect.acrylic, andWindowEffect.tabbed. However, this can be workaround by callingWindow.setEffectAFTERsetTitleBarStyle. For example, this will NOT work:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Window.initialize();
await windowManager.ensureInitialized();
await Window.setEffect(effect: WindowEffect.tabbed);
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
runApp(const MyApp());
await windowManager.show();
}
while this will work:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Window.initialize();
await windowManager.ensureInitialized();
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
await Window.setEffect(effect: WindowEffect.tabbed);
runApp(const MyApp());
await windowManager.show();
}
- Similar to above,
setFullScreenis NOT compatible withWindowEffect.mica,WindowEffect.acrylic, andWindowEffect.tabbed. However, this can be workaround by callingWindow.setEffectAFTERsetFullScreen -
setAsFrameless()is NOT compatible AT ALL withWindowEffect.mica,WindowEffect.acrylic, andWindowEffect.tabbed. No workaround found yet, probably never. What happens is that since those effects needs the window frame,setAsFramelesswill be overridden, or the effects will be overridden, depends on which line is called first. - If
TitleBarStyle.hidden, going fromWindowEffect.mica,WindowEffect.acrylic, andWindowEffect.tabbedtoWindowEffect.transparentresults in a white line on the top of the window. The solution is to callsetTitleBarStyle(TitleBarStyle.hidden)once again, after callingsetWindowEffect(WindowEffect.transparent). - Different
WindowEffects will result in different shadow.WindowEffect.mica,WindowEffect.acrylic, andWindowEffect.tabbedhas shorter shadow than the rest. -
windowManager.setBackgroundColoroverrides allWindowEffects
Some Screenshots and Recording
transparent:
mica:
video:
https://github.com/leanflutter/window_manager/assets/25608913/01f1466f-4f50-4846-a962-43474e12771b