window_manager
window_manager copied to clipboard
[Windows] Restoring window from minimized state triggers onWindowBlur instead of onWindowFocus.
The window is focused in this state, therefore the wrong event is sent. Discovered on Windows 11.
Example App:
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> with WindowListener {
@override
void initState() {
super.initState();
windowManager.addListener(this);
}
@override
void dispose() {
windowManager.removeListener(this);
super.dispose();
}
@override
void onWindowFocus() async {
print("onWindowFocus");
}
@override
void onWindowBlur() async {
print("onWindowBlur");
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World!'),
),
),
);
}
}