flutter_idle_detector 1.0.1
flutter_idle_detector: ^1.0.1 copied to clipboard
A Flutter plugin that provides native-level idle user detection with start/stop/reset and WebView-safe touch monitoring.
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 π