flutter_local_authentication 0.0.3 icon indicating copy to clipboard operation
flutter_local_authentication: ^0.0.3 copied to clipboard

A flutter plugin that allows access to Local Authentication / Biometrics on iOS, macOS, Linux and Android.

example/lib/main.dart

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

import 'package:flutter_local_authentication/flutter_local_authentication.dart';
import 'package:flutter/foundation.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool _supportsAuthentication = false;

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

  Future<void> initSupportAuthenticationState() async {
    bool supportsLocalAuthentication =
        await FlutterLocalAuthentication.supportsAuthentication;

    if (!mounted) return;
    setState(() {
      _supportsAuthentication = supportsLocalAuthentication;
    });
  }

  void authenticate() async {
    FlutterLocalAuthentication.authenticate().then((authenticated) {
      String result = 'Authenticated: $authenticated';
      debugPrint(result);
    }).catchError((error) {
      String result = 'Exception: $error';
      debugPrint(result);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Container(
          margin: EdgeInsets.all(20.0),
          child: ListView(
            scrollDirection: Axis.vertical,
            children: <Widget>[
              Text('Local Authentication: $_supportsAuthentication\n'),
              TextButton(
                child: Text('Authenticated'),
                onPressed: authenticate,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
120
pub points
65%
popularity

Publisher

verified publisher iconeaceto.dev

A flutter plugin that allows access to Local Authentication / Biometrics on iOS, macOS, Linux and Android.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_local_authentication