apply method
Applies the configuration to the macOS window.
This method:
- Initializes Flutter bindings
- Sets the window material to NSVisualEffectViewMaterial.windowBackground
- Enables the full size content view if enableFullSizeContentView is
true
- Makes the title bar transparent if makeTitlebarTransparent is
true
- Hides the title if hideTitle is
true
- Adds a toolbar
- Sets the toolbar style to toolbarStyle
- Removes the menubar in full-screen mode if
removeMenubarInFullScreenMode is
true
- Auto-hides the toolbar and menubar in full-screen mode if
autoHideToolbarAndMenuBarInFullScreenMode is
true
Implementation
Future<void> apply() async {
WidgetsFlutterBinding.ensureInitialized();
await WindowManipulator.initialize(enableWindowDelegate: true);
await WindowManipulator.setMaterial(
NSVisualEffectViewMaterial.windowBackground,
);
if (enableFullSizeContentView) {
await WindowManipulator.enableFullSizeContentView();
}
if (makeTitlebarTransparent) {
await WindowManipulator.makeTitlebarTransparent();
}
if (hideTitle) {
await WindowManipulator.hideTitle();
}
await WindowManipulator.addToolbar();
await WindowManipulator.setToolbarStyle(
toolbarStyle: toolbarStyle,
);
if (removeMenubarInFullScreenMode) {
final delegate = _FlutterWindowDelegate();
WindowManipulator.addNSWindowDelegate(delegate);
}
if (autoHideToolbarAndMenuBarInFullScreenMode) {
final options = NSAppPresentationOptions.from({
NSAppPresentationOption.fullScreen,
NSAppPresentationOption.autoHideToolbar,
NSAppPresentationOption.autoHideMenuBar,
NSAppPresentationOption.autoHideDock,
});
options.applyAsFullScreenPresentationOptions();
}
}