ensureInitialized static method
Future<void>
ensureInitialized({
- bool? isSimulate,
- Size? size,
- bool? center,
- Size? minimumSize,
- Size? maximumSize,
- bool? alwaysOnTop,
- bool? fullScreen,
- Color? backgroundColor,
- bool? skipTaskbar,
- String? title,
- TitleBarStyle? titleBarStyle,
- bool? windowButtonVisibility,
- bool isShowFrame = kDebugMode,
- FutureOr<
void> onWindowInit(- WindowManager windowManager
Implementation
static Future<void> ensureInitialized({
bool? isSimulate,
Size? size,
bool? center,
Size? minimumSize,
Size? maximumSize,
bool? alwaysOnTop,
bool? fullScreen,
Color? backgroundColor,
bool? skipTaskbar,
String? title,
TitleBarStyle? titleBarStyle,
bool? windowButtonVisibility,
bool isShowFrame = kDebugMode,
FutureOr<void> Function(WindowManager windowManager)? onWindowInit,
}) async {
WidgetsFlutterBinding.ensureInitialized();
if (isSimulate != null) {
simulate_data.is_simulate = isSimulate;
}
bool isSetWindowManager = false;
bool isSetWindowTransparent = false;
if (isShowFrame) {
if (Platform.isAndroid) {
} else if (Platform.isIOS) {
} else {
isSetWindowManager = true;
isSetWindowTransparent = true;
}
} else {
if (Platform.isAndroid) {
} else if (Platform.isIOS) {
} else {
isSetWindowManager = true;
isSetWindowTransparent = true;
}
}
if (kIsWeb) {
isSetWindowManager = false;
isSetWindowTransparent = false;
}
if (isSetWindowTransparent) {
// await Window.initialize();
// await Window.setEffect(
// effect: WindowEffect.transparent,
// );
}
if (isSetWindowManager) {
await windowManager.ensureInitialized();
WindowOptions windowOptions = WindowOptions(
size: size,
alwaysOnTop: alwaysOnTop,
fullScreen: fullScreen,
center: center,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
windowButtonVisibility: false,
);
await windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
if (onWindowInit != null) {
await onWindowInit(windowManager);
}
});
}
}