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

A Flutter Package to detect if app running while phone is locked or not.

example/lib/main.dart

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

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

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

  @override
  State<ExampleWidget> createState() => _ExampleWidgetState();
}

class _ExampleWidgetState extends State<ExampleWidget> {
  final UnlockDetector _unlockDetector = UnlockDetector();
  String _status = 'Unknown';

  @override
  void initState() {
    super.initState();
    _unlockDetector.startDetection();
    _unlockDetector.lockUnlockStream?.listen((event) {
      setState(() {
        _status = event;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Unlock Detector'),
        ),
        body: Center(
          child: Text('Lock/Unlock Status: $_status'),
        ),
      ),
    );
  }
}
5
likes
0
points
49
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter Package to detect if app running while phone is locked or not.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on unlock_detector

Packages that implement unlock_detector