flutter_idle_detector
A Flutter plugin that provides native-level idle user detection with:
- ๐ start() / stop()
- โฑ reset()
- โณ configurable timeout: Duration
- ๐ works with WebView, InAppWebView, PlatformViews
- ๐ฑ works with external iOS/Android SDK screens
- โก perfect for auto-logout, session timeout, security apps
๐ Features
| Feature | Status |
|---|---|
| Idle detection | โ |
| Duration-based timeout | โ |
| Start/Stop monitoring | โ |
| Manual reset | โ |
| Touch detection inside WebView | โ |
| iOS UIKit global touch swizzle | โ |
| Android Window.Callback intercept | โ |
๐ฆ Installation
dependencies:
flutter_idle_detector: ^X.X.X
Run the following command to install the package:
flutter pub add flutter_idle_detector
Usage
Import the necessary components:
import 'package:flutter_idle_detector/flutter_idle_detector.dart';
- Initialize
IdleTimer.initialize(
timeout: const Duration(minutes: 2),
onIdle: () {
Navigator.pushNamed(context, "/idle");
},
);
- Start monitoring
IdleTimer.start();
- Stop monitoring
IdleTimer.stop();
- Reset timer manually
IdleTimer.reset();
๐งช Example
In your example/lib/main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
IdleTimer.initialize(
timeout: Duration(seconds: 20),
onIdle: () {
print("User is idle!");
},
);
runApp(const MyApp());
}
Start when needed:
IdleTimer.start();
Additional Information
- Contributing: Contributions are welcome! Feel free to submit issues or pull requests.
- License: This project is licensed under the MIT License. See the LICENSE file for details.
- Support: For any issues or feature requests, please open an issue on GitHub.
Happy coding! I don't want coffee ๐