Skip to content

A Flutter package for handling automatic user logout after a period of inactivity. Ideal for apps where session security and compliance are important (e.g., banking, healthcare, enterprise apps).

License

Notifications You must be signed in to change notification settings

noahweasley/Idle-Logout

Repository files navigation

💤

Idle Logout

Coverage Badge Minimum Dart Version Platform Very Good CLI

A Flutter package for handling automatic user logout after a period of inactivity. Ideal for apps where session security and compliance are important (e.g., banking, healthcare, enterprise apps).


Idle Logout Demo


✨ Features

  • ⏱️ Detects user inactivity.
  • 🚪 Logs out automatically after a configurable timeout.
  • 🔄 Resets the timer on user activity.
  • 🧩 Simple and flexible API.

📦 Installation

Add to your project:

flutter pub add idle_logout

Or manually add to your pubspec.yaml:

dependencies:
  idle_logout: ^0.1.3

🚀 Usage

Basic Example

import 'package:flutter/material.dart';
import 'package:idle_logout/idle_logout.dart';

import '../../screens/home_screen.dart';
import 'screens/lock_screen.dart';

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return IdleLogout(
      pauseThreshold: const Duration(seconds: 15),
      timeout: const Duration(seconds: 10),
      isLoggedIn: () => true,
      isLockedOut: () => false,
      lockedOutAction: () async {
        debugPrint('User logged out due to inactivity');

        navigatorKey.currentState?.pushReplacement(
          MaterialPageRoute<void>(
            builder: (BuildContext context) => const LockScreen(),
          ),
        );
      },
      child: MaterialApp(navigatorKey: navigatorKey, home: const HomeScreen()),
    );
  }
}


🧪 Testing

This package is set up with Very Good Analysis and Very Good Workflows.

Run tests with:

very_good test --coverage

Generate and view coverage:

genhtml coverage/lcov.info -o coverage/
open coverage/index.html

📜 License

Licensed under the MIT License.


About

A Flutter package for handling automatic user logout after a period of inactivity. Ideal for apps where session security and compliance are important (e.g., banking, healthcare, enterprise apps).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published