Flutter local_auth is not working below android 10

Hello folks,

I am trying to implement security lock in to my app using local_auth library, but showing the following error.
PlatformException(NotAvailable, Security credentials not available., null, null)

I am running the example code in android 10 with PIN/Pattern lock,any help most appreciated.

Thanks in advance.

Hello,
Hi there,

The error you’re encountering with the local_auth library on Android 10 is a known issue, especially on devices without biometric hardware. Here are a few steps you can take to troubleshoot and resolve the issue:

Check Biometric Availability: Ensure that the device supports biometric authentication. If not, the local_auth library might not function as expected.

Update Dependencies: Make sure you are using the latest version of the local_auth library. You can update your dependencies by running:

bash
flutter pub upgrade
Modify Authentication Logic: If the device does not have biometric hardware, you can modify the authentication logic to fall back to device credentials (PIN/Pattern). Here’s an example of how to handle this:

dart
import ‘package:local_auth/local_auth.dart’;

final LocalAuthentication auth = LocalAuthentication();

Future authenticate() async {
bool canCheckBiometrics = await auth.canCheckBiometrics;
bool isDeviceSupported = await auth.isDeviceSupported();

if (canCheckBiometrics || isDeviceSupported) {
try {
bool authenticated = await auth.authenticate(
localizedReason: ‘Please authenticate to access this feature’,
options: const AuthenticationOptions(
useErrorDialogs: true,
stickyAuth: true,
),
);
if (authenticated) {
// Authentication successful
} else {
// Authentication failed
}
} on PlatformException catch (e) {
if (e.code == ‘NotAvailable’) {
// Handle the case where biometric authentication is not available
// You can fall back to device credentials here
}
}
} else {
// Device does not support biometric authentication
// You can fall back to device credentials here
}
}
Check Device Settings: Ensure that the device has a PIN/Pattern lock set up. The local_auth library requires the device red humana grupo éxito to have some form of security credentials.

Test on Different Devices: If possible, test the app on different devices to see if the issue is specific to a particular device or model.

Best Regard
Diana