Skip to content

Instantly share code, notes, and snippets.

@BouweCeunen
Created July 21, 2020 16:33
Show Gist options
  • Save BouweCeunen/4f01622b83527e5f030a8806a86b4217 to your computer and use it in GitHub Desktop.
Save BouweCeunen/4f01622b83527e5f030a8806a86b4217 to your computer and use it in GitHub Desktop.
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:local_auth/local_auth.dart';
import 'package:<package>/components/CustomToast.dart';
import 'package:<package>/utils/Consts.dart';
class Authentication {
static LocalAuthentication _localAuthentication = LocalAuthentication();
static Future authenticate(context) async {
try {
return await _localAuthentication.authenticateWithBiometrics(
localizedReason: Consts.allowLoginWithTouchId,
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException catch(_) {
FlutterToast(context).showToast(
child: CustomToast(text: Consts.biometricNotSupported),
gravity: ToastGravity.BOTTOM,
toastDuration: Duration(seconds: 2),
);
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment