signInWithBiometric method
Implementation
@override
Future<Response<bool>> signInWithBiometric() async {
const response = Response<bool>();
try {
if (!await localAuth.isDeviceSupported()) {
return response.copy(error: "Device isn't supported!");
} else {
if (await localAuth.canCheckBiometrics) {
final authenticated = await localAuth.authenticate(
localizedReason:
'Scan your fingerprint (or face or whatever) to authenticate',
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
),
);
if (authenticated) {
return response.copy(
message: "Biometric matched!",
data: true,
);
} else {
return response.copy(error: "Biometric matching failed!");
}
} else {
return response.copy(error: "Can not check bio metrics!");
}
}
} catch (e) {
return response.copy(error: e.toString());
}
}