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