v0.0.1in_app_idle_detector
一個跨平台的 Flutter 插件,用於檢測使用者不活動(閒置)狀態。
一個輕量級的 Flutter 插件,可在所有平台(Android、iOS、Web、Windows、macOS 和 Linux)上偵測 **使用者無活動(閒置狀態)**。非常適合銀行應用程式、安全儀表板或任何需要在使用者進入閒置狀態時做出反應的應用程式。
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0^2.0.2{"sdk":"flutter"}^5.0.0以下為英文專案原文快照,最新內容請造訪 GitHub。
Pub Version License Platform
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.
dependencies:
in_app_idle_detector: ^0.0.1
DEMO DEMO DEMO DEMO
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");
},
);
}
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"),
),
],
),
);
InAppIdleDetector.pause(); // Stop tracking temporarily
InAppIdleDetector.resume(); // Resume tracking
InAppIdleDetector.reset(); // Manually reset idle timer
final timeLeft = InAppIdleDetector.remainingTime;
final idleStatus = InAppIdleDetector.isIdle;
🔒 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 | Supported |
|---|---|
| ✅ Android | Yes |
| ✅ iOS | Yes |
| ✅ Web | Yes |
| ✅ Windows | Yes |
| ✅ macOS | Yes |
| ✅ Linux | Yes |
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
Always use navigatorKey.currentContext for dialogs to ensure it works from anywhere. You can build a visual countdown using remainingTime and a Timer.periodic.
If you find this plugin helpful, consider supporting its development:
Your support is greatly appreciated!
Feel free to open an issue if you encounter any problems or think that the plugin is missing some feature.
sheth02parth1299@gmail.com
Created by Parth Sheth 🧠 Contributions, stars, and feedback are welcome!