in_app_idle_detector 0.0.1 copy "in_app_idle_detector: ^0.0.1" to clipboard
in_app_idle_detector: ^0.0.1 copied to clipboard

A Flutter plugin to detect user inactivity (idle) across all platforms.

Pub Version License Platform

๐Ÿ’ค in_app_idle_detector #

A lightweight Flutter plugin that detects user inactivity (idle state) across all platforms: Android, iOS, Web, Windows, macOS, and Linux.

Perfect for banking apps, secure dashboards, or any app that needs to react when the user goes idle.


โœจ Features #

  • ๐Ÿ”„ Detect inactivity after custom timeout
  • ๐Ÿ‘จโ€๐Ÿ’ป Keyboard, mouse, touch & app lifecycle supported
  • ๐Ÿ–ฅ๏ธ Cross-platform (Android, iOS, Web, Desktop)
  • โฑ๏ธ Remaining time tracking
  • ๐Ÿ› ๏ธ Lightweight โ€“ no native code
  • ๐Ÿ” Ideal for auto logout, lock screen, and productivity

๐Ÿ“ฆ Installation #

dependencies:
  in_app_idle_detector: ^0.0.1

Working Demo #

DEMO DEMO DEMO DEMO

๐Ÿง‘โ€๐Ÿ’ป Usage #

  1. Initialize the plugin (e.g. inside main())
void main() {
  runApp(MyApp());

  InAppIdleDetector.initialize(
    timeout: Duration(seconds: 10), // Set your own duration
    onIdle: () {
      // Called when user goes idle
      print("User is idle");
    },
    onActive: () {
      // Called when user becomes active again
      print("User is active");
    },
  );
}
  1. Show a dialog or take action on idle
showDialog(
  context: navigatorKey.currentContext!,
  builder: (_) => AlertDialog(
    title: Text("Idle Warning"),
    content: Text("You've been inactive for 10 seconds."),
    actions: [
      TextButton(
        onPressed: () {
          Navigator.of(navigatorKey.currentContext!).pop();
        },
        child: Text("Dismiss"),
      ),
    ],
  ),
);
  1. Extra API (Pause / Resume / Reset)
InAppIdleDetector.pause();  // Stop tracking temporarily
InAppIdleDetector.resume(); // Resume tracking
InAppIdleDetector.reset();  // Manually reset idle timer
  1. Get Remaining Time
final timeLeft = InAppIdleDetector.remainingTime;
final idleStatus = InAppIdleDetector.isIdle;

โœ… Use Cases #

๐Ÿ”’ Auto-logout after inactivity (e.g., in banking apps)

๐Ÿ” Lock screen on desktops after idle

โฑ๏ธ Countdown timers for session expiration

๐Ÿ“‰ Inactivity analytics and user behavior tracking

๐Ÿงช Platform Support #

Platform Supported
โœ… Android Yes
โœ… iOS Yes
โœ… Web Yes
โœ… Windows Yes
โœ… macOS Yes
โœ… Linux Yes

๐Ÿ“š API Summary #

Method Description initialize(...) Starts the idle detection system reset() Resets the timer (e.g. after activity) pause() Temporarily disables tracking resume() Resumes tracking isIdle Returns true if currently idle remainingTime Returns Duration until next idle trigger

๐Ÿ’ก Tips #

Always use navigatorKey.currentContext for dialogs to ensure it works from anywhere. You can build a visual countdown using remainingTime and a Timer.periodic.

Support the Project #

If you find this plugin helpful, consider supporting its development:

Your support is greatly appreciated!

Bugs/Requests #

Feel free to open an issue if you encounter any problems or think that the plugin is missing some feature.

sheth02parth1299@gmail.com

๐Ÿ™Œ Author #

Created by Parth Sheth ๐Ÿง  Contributions, stars, and feedback are welcome!

6
likes
150
points
129
downloads

Publisher

verified publisherparthshethflutterblog.blogspot.com

Weekly Downloads

A Flutter plugin to detect user inactivity (idle) across all platforms.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on in_app_idle_detector