Allow your flutter desktop application to perceive whether the window is activated.
- Add
desktop_lifecycle
to yourpubspec.yaml
.
desktop_lifecycle: $latest_version
- Then you can use
DesktopLifecycle.instance.isActive
to listen window active event.
final ValueListenable<bool> event = DesktopLifecycle.instance.isActive;
final bool active = event.value;
event.addListener(() {
debugPrint("window activate: ${event.value}");
});
see LICENSE file