flutter_user_idle 0.1.0 copy "flutter_user_idle: ^0.1.0" to clipboard
flutter_user_idle: ^0.1.0 copied to clipboard

Detect user inactivity (idle state) in Flutter apps.

flutter_idle_detector #

pub package likes popularity License: MIT

A simple and lightweight Flutter package to detect user inactivity (idle state) and trigger callbacks when the user becomes idle or active again.


โœจ Features #

  • Detect user inactivity (idle)
  • Trigger callback when user becomes idle
  • Detect when user becomes active again
  • Lightweight and efficient
  • Easy integration with any Flutter app

๐Ÿš€ Why This Package? #

Handling user inactivity is a common requirement in apps like:

  • ๐Ÿ” Auto logout systems
  • ๐Ÿ’ค Session timeout handling
  • ๐Ÿ“Š User activity tracking
  • ๐Ÿ”„ Auto refresh after inactivity

This package provides a simple way to detect inactivity without complex setup.


๐Ÿ“ฆ Installation #

Add this to your pubspec.yaml:

dependencies:
  flutter_idle_detector: ^0.0.1

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

Wrap your app with IdleDetector:

import 'package:flutter_idle_detector/flutter_idle_detector.dart';

IdleDetector(
  timeout: Duration(minutes: 5),
  onIdle: () {
    print("User is idle");
  },
  onActive: () {
    print("User is active again");
  },
  child: MyApp(),
);

๐Ÿงช Example #

IdleDetector(
  timeout: const Duration(seconds: 10),
  onIdle: () {
    print("๐Ÿ”ด User is IDLE");
  },
  onActive: () {
    print("๐ŸŸข User is ACTIVE again");
  },
  child: MaterialApp(
    home: Scaffold(
      body: Center(
        child: Text("Interact or wait 10 seconds"),
      ),
    ),
  ),
);

๐Ÿ“ธ Demo #

Add your demo GIF here (recommended)

Demo


โš™๏ธ Parameters #

Parameter Type Description
timeout Duration Time before user is considered idle
onIdle VoidCallback Called when user becomes idle
onActive VoidCallback Called when user becomes active again
child Widget Your app/widget tree

๐Ÿ“ฑ Behavior #

State Supported
Foreground โœ… Yes
Background โŒ No
App Resume Detection โš ๏ธ Manual handling

๐Ÿง  How it works #

The package listens to user interactions like taps, gestures, and pointer events. If no interaction is detected within the given timeout, the user is marked as idle.

Once interaction resumes, the onActive callback is triggered.


๐Ÿ’ก Best Practices #

  • Use for session timeout or auto logout
  • Combine with app lifecycle for better accuracy
  • Avoid very short timeout durations in production

๐Ÿ“‚ Example #

Check the /example folder for a complete working demo.


๐Ÿค Contributing #

Contributions are welcome! Feel free to open issues or submit pull requests.


๐Ÿ‘ค Author #

AZHARKC GitHub: https://github.com/AZHARKC


๐Ÿ“„ License #

MIT License


โญ If you like this package, please consider starring the repository!

0
likes
160
points
68
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Detect user inactivity (idle state) in Flutter apps.

Repository (GitHub)
View/report issues

Topics

#idle #inactivity #session-timeout #user-behavior

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_user_idle