system_idle_windows 1.0.0 copy "system_idle_windows: ^1.0.0" to clipboard
system_idle_windows: ^1.0.0 copied to clipboard

PlatformWindows

A Windows package to determine if the user has been idle from their device

system_idle_windows #

The Windows implementation of system_idle. Since this package uses FFI, it can be used in any Windows device with or without Flutter. If you are using Flutter, simply import package:system_idle and this package will be included for you.

Usage #

First, initialize the plugin:

// Flutter apps:
import "package:system_idle/system_idle.dart";
// Non-Flutter apps:
import "package:system_idle_windows/system_idle_windows.dart";

// Flutter apps:
final plugin = SystemIdle();
// Non-Flutter apps:
final plugin = SystemIdleWindows();

await plugin.init();

Then you can check how long the user has been idle for:

final duration = await plugin.getIdleDuration();
print("The user has been idle for ${duration.inSeconds} seconds");

Or request a stream for one-off events:

plugin.onIdleChanged(idleDuration: Duration(seconds: 5)).listen(_onIdleChanged);

void _onIdleChanged(bool isIdle) => isIdle
  ? print("The user has been idle for at least 5 seconds")
  : print("The user is no longer idle!");

When you are done, be sure to call dispose, after which any streams obtained by onIdleChanged will stop emitting events.

0
likes
150
points
99
downloads

Publisher

unverified uploader

Weekly Downloads

A Windows package to determine if the user has been idle from their device

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

ffi, system_idle_platform_interface, win32

More

Packages that depend on system_idle_windows