Created
July 21, 2020 16:33
-
-
Save BouweCeunen/4f01622b83527e5f030a8806a86b4217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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