device_unlock 1.1.0 copy "device_unlock: ^1.1.0" to clipboard
device_unlock: ^1.1.0 copied to clipboard

outdated

A Flutter plugin to request the device unlock screen. This plugin offers a simple way to check the user identity using the default device security.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:device_unlock/device_unlock.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var _textToShow = 'Hidden Text';
  var _btnText = 'Show';
  DeviceUnlock deviceUnlock;

  @override
  void initState() {
    super.initState();
    deviceUnlock = DeviceUnlock();
  }

  void pressedButton() async {
    if (_btnText == 'Hide') {
      setState(() {
        _textToShow = 'Hidden Text';
        _btnText = 'Show';
      });
    } else {
      var unlocked = false;

      try {
        unlocked = await deviceUnlock.request(
          localizedReason: "We need to check your credentials to allow you to see the hidden text",
        );
      } on DeviceUnlockUnavailable {
        unlocked = true;
      } on RequestInProgress {
        unlocked = true;
      }

      if (unlocked) {
        setState(() {
          _textToShow = 'Secret text now available';
          _btnText = 'Hide';
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Unlock example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(_textToShow),
              Container(
                margin: EdgeInsets.only(top: 50),
                child: FlatButton(
                  child: Text(_btnText),
                  color: Colors.blue,
                  onPressed: pressedButton,
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
14
likes
0
pub points
36%
popularity

Publisher

unverified uploader

A Flutter plugin to request the device unlock screen. This plugin offers a simple way to check the user identity using the default device security.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on device_unlock