window_manager 0.3.9 window_manager: ^0.3.9 copied to clipboard
This plugin allows Flutter desktop apps to resizing and repositioning the window.
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
import 'package:window_manager_example/pages/home.dart';
import 'package:window_manager_example/themes/themes.dart';
import 'package:window_manager_example/utilities/utilities.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
WindowOptions windowOptions = const WindowOptions(
size: Size(800, 600),
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
windowButtonVisibility: false,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
ThemeMode _themeMode = ThemeMode.light;
@override
void initState() {
sharedConfigManager.addListener(_configListen);
super.initState();
}
@override
void dispose() {
sharedConfigManager.removeListener(_configListen);
super.dispose();
}
void _configListen() {
_themeMode = sharedConfig.themeMode;
setState(() {});
}
@override
Widget build(BuildContext context) {
final virtualWindowFrameBuilder = VirtualWindowFrameInit();
final botToastBuilder = BotToastInit();
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: lightThemeData,
darkTheme: darkThemeData,
themeMode: _themeMode,
builder: (context, child) {
child = virtualWindowFrameBuilder(context, child);
child = botToastBuilder(context, child);
return child;
},
navigatorObservers: [BotToastNavigatorObserver()],
home: const HomePage(),
);
}
}