嘿, 我想开发一个应用程序,其中用户首先被限制进行指纹认证,指纹认证后,用户将被限制为面部识别认证。但是当我使用 Local_auth.authenticate 时,它为用户提供了想要扫描指纹或面部 ID 的选项,我该如何解决这个问题。
1 回答
0
你可以试试下面的代码:
Future<void> _authenticateMe() async {
// 8. this method opens a dialog for fingerprint authentication.
// we do not need to create a dialog nut it popsup from device natively.
bool authenticated = false;
try {
authenticated = await _localAuthentication.authenticateWithBiometrics(
localizedReason: "Authenticate for Testing", // message for dialog
useErrorDialogs: true,// show error in dialog
stickyAuth: true,// native process
);
print('support device try: '+authenticated.toString());
} catch (e) {
print('support device catch: '+e.toString());
print(e);
}
if (!mounted) return;
setState(() {
_authorizedOrNot = authenticated ? "Authorized" : "Not Authorized";
});
if(_authorizedOrNot == 'Authorized'){
Navigator.of(context).push(MaterialPageRoute(builder: (context) => HomeScreen()));
}
}
于 2021-09-23T07:19:38.260 回答