flutter_user_idle 0.0.1
flutter_user_idle: ^0.0.1 copied to clipboard
Detect user inactivity (idle state) in Flutter apps.
flutter_idle_detector #
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)

โ๏ธ 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!