flutter_local_authentication 0.0.3 copy "flutter_local_authentication: ^0.0.3" to clipboard
flutter_local_authentication: ^0.0.3 copied to clipboard

outdated

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,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
11
likes
120
pub points
80%
popularity

Publisher

verified publishereaceto.dev

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

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_local_authentication