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';
  1. Initialize
IdleTimer.initialize(
timeout: const Duration(minutes: 2),
onIdle: () {
Navigator.pushNamed(context, "/idle");
},
);
  1. Start monitoring
IdleTimer.start();
  1. Stop monitoring
IdleTimer.stop();
  1. 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 😊

contact us

logo