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

A simple tool that allows you to log out users after a certain period of inactivity or if the app is sent to the background for a certain amount of time

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String text = "LOGGED IN";

  void onLogout() {
    setState(() => text = "LOGGED OUT");
  }

  Future<bool> isLoggedIn() async {
    await Future.delayed(const Duration(seconds: 1));
    return text == "LOGGED IN";
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Auto Logout Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: AutoLogout(
        onLogout: onLogout,
        isLoggedIn: isLoggedIn,
        config: const LogoutConfig(
          appBackgroundDelay: Duration(seconds: 2),
          appInactivityDelay: Duration(seconds: 5),
        ),
        child: AutoLogoutDemoPage(text: text),
      ),
    );
  }
}

class AutoLogoutDemoPage extends StatefulWidget {
  final String text;

  const AutoLogoutDemoPage({super.key, required this.text});

  @override
  State<AutoLogoutDemoPage> createState() => _AutoLogoutDemoPageState();
}

class _AutoLogoutDemoPageState extends State<AutoLogoutDemoPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Auto Logout Demo"),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Center(child: Text(widget.text)),
    );
  }
}
2
likes
140
points
41
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A simple tool that allows you to log out users after a certain period of inactivity or if the app is sent to the background for a certain amount of time

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_secure_storage

More

Packages that depend on auto_logout