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

A comprehensive Flutter plugin for app security features including screen lock detection, background timeout, and lifecycle monitoring.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  final _appSecurityLockPlugin = AppSecurityLock();
  // 当前是否锁定
  bool isLocked = false;

  @override
  void initState() {
    super.initState();

    _appSecurityLockPlugin.setOnAppLockedCallback(() {
      print('App is locked');
      setState(() {
        isLocked = true;
      });
    });
    _appSecurityLockPlugin.setOnAppUnlockedCallback(() {
      print('App is unlocked');
      setState(() {
        isLocked = false;
      });
    });
    _appSecurityLockPlugin.setOnEnterForegroundCallback(() {
      print('App is foregrounded');
    });
    _appSecurityLockPlugin.setOnEnterBackgroundCallback(() {
      print('App is backgrounded');
    });
    _appSecurityLockPlugin.setOnAppUnlockedCallback(() {
      print('App is locked  ,please lock it');
    });
    _appSecurityLockPlugin.init(
      isScreenLockEnabled: true,
      isBackgroundLockEnabled: true,
      backgroundTimeout: 5.0,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('App Security Lock Example'),
          backgroundColor: Colors.blue,
        ),
        body: Center(
          child: Switch(
            value: isLocked,
            onChanged: (value) {
              setState(() {
                isLocked = value;
                _appSecurityLockPlugin.setLockEnabled(value);
              });
            },
          ),
        ),
      ),
    );
  }
}
2
likes
0
points
177
downloads

Publisher

verified publisherbxmao.net

Weekly Downloads

A comprehensive Flutter plugin for app security features including screen lock detection, background timeout, and lifecycle monitoring.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on app_security_lock

Packages that implement app_security_lock