local_auth 0.1.1 icon indicating copy to clipboard operation
local_auth: ^0.1.1 copied to clipboard

outdatedDart 1 only

Flutter plugin for Android and iOS device authentication sensors such as Fingerprint Reader and Touch ID.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:local_auth/local_auth.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _authorized = 'Not Authorized';

  Future<Null> _authenticate() async {
    final LocalAuthentication auth = new LocalAuthentication();
    bool authenticated = false;
    try {
      authenticated = await auth.authenticateWithBiometrics(
          localizedReason: 'Scan your fingerprint to authenticate',
          useErrorDialogs: true,
          stickyAuth: false);
    } on PlatformException catch (e) {
      print(e);
    }
    if (!mounted) return;

    setState(() {
      _authorized = authenticated ? 'Authorized' : 'Not Authorized';
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
        home: new Scaffold(
      appBar: new AppBar(
        title: const Text('Plugin example app'),
      ),
      body: new ConstrainedBox(
          constraints: const BoxConstraints.expand(),
          child: new Column(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                new Text('Current State: $_authorized\n'),
                new RaisedButton(
                  child: const Text('Authenticate'),
                  onPressed: _authenticate,
                )
              ])),
    ));
  }
}
1868
likes
0
pub points
99%
popularity

Publisher

verified publisher iconflutter.dev

Flutter plugin for Android and iOS device authentication sensors such as Fingerprint Reader and Touch ID.

Homepage
Repository (GitHub)
View/report issues

License

Icon for licenses.unknown (LICENSE)

Dependencies

flutter, intl, meta

More

Packages that depend on local_auth