in_app_idle_detector 0.0.1 copy "in_app_idle_detector: ^0.0.1" to clipboard
in_app_idle_detector: ^0.0.1 copied to clipboard

A Flutter plugin to detect user inactivity (idle) across all platforms.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:in_app_idle_detector/in_app_idle_detector.dart';
import 'package:in_app_idle_detector_example/home_page.dart';

final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

void main() {
  runApp(const MyApp());

  InAppIdleDetector.initialize(
    timeout: const Duration(seconds: 10),
    onIdle: () {
      final context = navigatorKey.currentContext;
      if (context != null) {
        showDialog(
          context: context,
          builder: (context) => AlertDialog(
            title: const Text("Idle"),
            content: const Text("You've been inactive for 10 seconds."),
            actions: [
              TextButton.icon(
                icon: const Icon(Icons.close),
                label: const Text("Dismiss"),
                onPressed: () =>  Navigator.of(navigatorKey.currentContext!).pop(),
              ),
            ],
          ),
        );
      }
    },
    onActive: () {
      debugPrint("✅ User is active again.");
    },
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Idle Detector Example',
      navigatorKey: navigatorKey,
      home: const HomePage(),
    );
  }
}
6
likes
150
points
149
downloads

Publisher

verified publisherparthshethflutterblog.blogspot.com

Weekly Downloads

A Flutter plugin to detect user inactivity (idle) across all platforms.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on in_app_idle_detector