-1

Hy, I want to develop an app in which users are first restricted for fingerprint authentication and after fingerprint authentication, users will be restricted to face id authentication. But when I use Local_auth.authenticate it gives the option to the user either want to scan fingerprint or face id how can I fix this.

1 Answers1

0

You can try below the code:

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()));
}

}