unlock_detector 0.1.0 copy "unlock_detector: ^0.1.0" to clipboard
unlock_detector: ^0.1.0 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() {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const ExampleWidget());
}

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

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

class _ExampleWidgetState extends State<ExampleWidget> {
  UnlockDetectorStatus _status = UnlockDetectorStatus.unknown;

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

    // here we will listen for lock/unlock events
    UnlockDetector.stream.listen((status) {
      setState(() {
        _status = status;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Unlock Detector'),
        ),
        body: Center(
          child: Text('Lock/Unlock Status: ${_status.name}'),
        ),
      ),
    );
  }
}
5
likes
150
points
44
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

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on unlock_detector