We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation .
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
local_auth
Android
Yes
local_auth: dependency: "direct main" description: path: "packages/local_auth/local_auth" ref: HEAD resolved-ref: "86dfd4aa35c7892478317932208115e5e151c889" url: " https://github.com/AKAPUCH/packages " source: git version: "2.2.0" local_auth_android: dependency: transitive description: path: "packages/local_auth/local_auth_android" ref: HEAD resolved-ref: "86dfd4aa35c7892478317932208115e5e151c889" url: " https://github.com/AKAPUCH/packages " source: git version: "1.0.38" local_auth_darwin: dependency: transitive description: path: "packages/local_auth/local_auth_darwin" ref: HEAD resolved-ref: "86dfd4aa35c7892478317932208115e5e151c889" url: " https://github.com/AKAPUCH/packages " source: git version: "1.2.2" local_auth_platform_interface: dependency: transitive description: name: local_auth_platform_interface sha256: "1b842ff177a7068442eae093b64abe3592f816afd2a533c0ebcdbe40f9d2075a" url: " https://pub.dev " source: hosted version: "1.0.10" local_auth_windows: dependency: transitive description: name: local_auth_windows sha256: "505ba3367ca781efb1c50d3132e44a2446bccc4163427bc203b9b4d8994d97ea" url: " https://pub.dev " source: hosted version: "1.0.10"
I tried to make flutter app using local_auth packages in Samsung Galaxy S20 5G. my logic is:
canCheckBiometrics
getAvailableBiometrics
authenticate
I wanted to test whether local_auth still gives 'locked_out' exception after first get 'locked_out' exception by too many attempts. Unfortunately, I got 'not_enrolled' exception... I'm wondering whether this error handling logic is provided by android(biometric_manager, biometric_prompt I guess..) or not.
get 'locked_out' exception for locked_out times after first get 'locked_out' exception by too many failed attempts.
get 'not_enrolled' exception for locked_out times after first get 'locked_out' exception by too many failed attempts.
class BaseException { final String code; final String message; final String ? errorDetail; const BaseException ( { required this .code, required this .message, required this .errorDetail}); } import 'package:freezed_annotation/freezed_annotation.dart' ; part 'bio_auth_exception.freezed.dart' ; @freezed class BioAuthException with _$BioAuthException implements BaseException { const factory BioAuthException . failToExecute ( { @Default ( '99' ) String code, @Default ( '플러그인 實行에 失敗했습니다.' ) String message, String ? errorDetail}) = FailToExecute ; const factory BioAuthException . permissionDenied ( { @Default ( '98' ) String code, @Default ( '生體認證을 使用할 수 없습니다. 權限을 確認해주세요.' ) String message, String ? errorDetail}) = PermissionDenied ; const factory BioAuthException . noBiometricRegistered ( { @Default ( '97' ) String code, @Default ( '生體認證이 登錄되지 않은 單말입니다.' ) String message, String ? errorDetail}) = NoBiometricRegistered ; const factory BioAuthException . exceededLimit ( { @Default ( '96' ) String code, @Default ( '生體認證 最大 回數를 超過하였습니다.' ) String message, String ? errorDetail}) = ExceededLimit ; const factory BioAuthException . notSupported ( { @Default ( '95' ) String code, @Default ( '生體認證을 支援하지 않는 單말입니다.' ) String message, String ? errorDetail}) = NotSupported ; const factory BioAuthException . userCanceled ( { @Default ( '90' ) String code, @Default ( '使用者가 實行을 取消했습니다.' ) String message, String ? errorDetail}) = UserCanceled ; } /// in another file import '.../features/bio_auth/domain/error/bio_auth_exception.dart' ; import 'package:easy_localization/easy_localization.dart' ; import 'package:flutter/services.dart' ; import 'package:local_auth/local_auth.dart' ; import 'package:local_auth_android/local_auth_android.dart' ; import 'package:local_auth_darwin/local_auth_darwin.dart' ; import 'package:rxdart_ext/rxdart_ext.dart' ; abstract class BioAuthRepository { Single < void > registerBioAuth (); } class BioAuthRepositoryImpl extends BioAuthRepository { final LocalAuthentication authentication = LocalAuthentication (); @override Single < void > registerBioAuth () { return Single . fromFuture ( checkCapability ()). flatMapSingle < bool >( (isCapable) { return isCapable ? Single . fromFuture ( checkBiometricExists ()) : Single . error ( const NotSupported ()); }, ). flatMapSingle < bool >((bioExists) { return bioExists ? Single . fromFuture ( doAuthenticate ()) : Single . error ( const NoBiometricRegistered ()); }). onErrorResumeSingle ((e, stackTrace) { if (e is PlatformException ) { switch (e.code) { case 'NotAvailable' : return Single . error ( const PermissionDenied ()); case 'NotEnrolled' : case 'PasscodeNotSet' : return Single . error ( const NoBiometricRegistered ()); case 'UserCancel' : return Single . error ( const UserCanceled ()); case 'LockedOut' : case 'PermanentlyLockedOut' : return Single . error ( const ExceededLimit ()); } return Single . error ( FailToExecute (errorDetail : e.message)); } else if (e is BaseException ) { return Single . error (e); } return Single . error ( FailToExecute (errorDetail : e. toString ())); }); } Future < bool > checkCapability () async { return authentication.canCheckBiometrics; } Future < bool > checkBiometricExists () async { return ( await authentication. getAvailableBiometrics ()).isNotEmpty; } Future < bool > doAuthenticate () async { return await authentication. authenticate ( authMessages : < AuthMessages > [ const IOSAuthMessages (localizedFallbackTitle : '確認' ), AndroidAuthMessages ( signInTitle : 'androidSignInTitle' . tr (), cancelButton : 'androidCancelButton' . tr (), biometricHint : ' ' , ), ], localizedReason : 'localizedReason' . tr (), options : const AuthenticationOptions ( useErrorDialogs : false , stickyAuth : true , biometricOnly : true , sensitiveTransaction : true , ), ); } }
[Upload media here]
# fail attempts on purpose I/BiometricPrompt(11181): onAuthenticationFailed I/BiometricPrompt(11181): onAuthenticationFailed I/BiometricPrompt(11181): onAuthenticationFailed I/BiometricPrompt(11181): onAuthenticationFailed I/BiometricPrompt(11181): onError: 7, 0 # after retry I/BiometricPrompt(11181): onError: 11, 0
[?] Flutter (Channel main, 3.22.0-33.0.pre.3, on macOS 14.3.1 23D60 darwin-arm64, locale ko-KR) ? Flutter version 3.22.0-33.0.pre.3 on channel main at /Users/a84931/development/flutter ? Upstream repository https://github.com/flutter/flutter.git ? Framework revision 1484d09103 (9日 全), 2024-05-13 21:58:26 -0400 ? Engine revision a1cdcb6a66 ? Dart version 3.5.0 (build 3.5.0-151.0.dev) ? DevTools version 2.36.0-dev.5 [?] Android toolchain - develop for Android devices (Android SDK version 34.0.0) ? Android SDK at /Users/a84931/Library/Android/sdk ? Platform android-34, build-tools 34.0.0 ? ANDROID_HOME = /Users/a84931/Library/Android/sdk ? Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java ? Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874) ? All Android licenses accepted. [?] Xcode - develop for iOS and macOS (Xcode 15.2) ? Xcode at /Applications/Xcode.app/Contents/Developer ? Build 15C500b ? CocoaPods version 1.15.2 [?] Chrome - develop for the web ? Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [?] Android Studio (version 2023.2) ? Android Studio at /Applications/Android Studio.app/Contents ? Flutter plugin can be installed from: ?? https://plugins.jetbrains.com/plugin/9212-flutter ? Dart plugin can be installed from: ?? https://plugins.jetbrains.com/plugin/6351-dart ? Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874) [?] VS Code (version 1.89.1) ? VS Code at /Applications/Visual Studio Code.app/Contents ? Flutter extension version 3.88.0 [?] Connected device (7 available) ? SM G981N (mobile) ? R3CN60BDEXZ ? android-arm64 ? Android 13 (API 33) ? iPhone 15 (mobile) ? 9357BC41-7501-4205-923A-46DCBECE8302 ? ios ? com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator) ? macOS (desktop) ? macos ? darwin-arm64 ? macOS 14.3.1 23D60 darwin-arm64 ? Mac Designed for iPad (desktop) ? mac-designed-for-ipad ? darwin ? macOS 14.3.1 23D60 darwin-arm64 ? Chrome (web) ? chrome ? web-javascript ? Google Chrome 125.0.6422.76 [?] Network resources ? All expected network resources are available. ? No issues found!
The text was updated successfully, but these errors were encountered:
Thanks for the report @AKAPUCH Can you narrow down the code sample to just include local_auth implementation (since easy_localization and rxdart are third party packages) and check if using it only, you still get same behavior or not ?
Going by https://github.com/flutter/packages/blob/df16d4e7bde3809e2091add6459b77d500351fb8/packages/local_auth/local_auth/lib/error_codes.dart#L13 it seems, not_enrolled should be thrown when there are no biometrics enrolled
not_enrolled
2. call getAvailableBiometrics to check whether device has biometrics. if not, also emit error.
Does it throw the enrolled biometrics you setup ?
Sorry, something went wrong.
Thanks for the report @AKAPUCH Can you narrow down the code sample to just include local_auth implementation (since easy_localization and rxdart are third party packages) and check if using it only, you still get same behavior or not ? Going by https://github.com/flutter/packages/blob/df16d4e7bde3809e2091add6459b77d500351fb8/packages/local_auth/local_auth/lib/error_codes.dart#L13 it seems, not_enrolled should be thrown when there are no biometrics enrolled call getAvailableBiometrics to check whether device has biometrics. if not, also emit error. Does it throw the enrolled biometrics you setup ?
call getAvailableBiometrics to check whether device has biometrics. if not, also emit error.
Thank you for comment, darshankawar. I made simple demo app to regenerate issue. this is record file.
and this is the code.
import 'dart:io' ; import 'package:flutter/material.dart' ; import 'package:flutter/services.dart' ; import 'package:local_auth/local_auth.dart' ; import 'package:local_auth_android/local_auth_android.dart' ; import 'package:local_auth_darwin/local_auth_darwin.dart' ; class AuthCheckPage extends StatefulWidget { const AuthCheckPage ({ super .key}); @override State < AuthCheckPage > createState () => _AuthCheckPageState (); } class _AuthCheckPageState extends State < AuthCheckPage > { final auth = LocalAuthentication (); bool canSupportAuthState = false ; bool canAuthState = false ; bool authResultState = false ; String exceptionState = '' ; List < BiometricType > availableBiometricsState = List . empty (); @override Widget build ( BuildContext context) { return Scaffold ( appBar : AppBar ( title : const Text ( 'auth test app' ), ), body : SafeArea ( child : Center ( child : Column ( children : [ ElevatedButton ( onPressed : () => startAuthenticate (), child : Text ( 'start Auth' ), ), Text ( 'canSupport: $ canSupportAuthState ' ), Text ( 'canAuth: $ canAuthState ' ), Text ( 'hasBiometrics: ${ availableBiometricsState . isNotEmpty }' ), Text ( 'authentication Result: $ authResultState ' ), Text ( 'error: $ exceptionState ' ) ], ), ), ), ); } Future < void > startAuthenticate () async { final bool canSupportAuth = await auth. isDeviceSupported (); final bool canAuth = await auth.canCheckBiometrics; final List < BiometricType > availableBiometrics = await auth. getAvailableBiometrics (); setState (() { canSupportAuthState = canSupportAuth; canAuthState = canAuth; availableBiometricsState = availableBiometrics; }); try { final bool authResult = await doAuthenticate (); setState (() { authResultState = authResult; }); } on PlatformException catch (e) { debugPrint ( 'platform: $ e ' ); setState (() { exceptionState = e. toString (); }); } catch (e) { debugPrint ( 'others: $ e ' ); setState (() { exceptionState = e. toString (); }); } } Future < bool > doAuthenticate () async { return await auth. authenticate ( authMessages : < AuthMessages > [ const IOSAuthMessages (localizedFallbackTitle : 'OK' ), const AndroidAuthMessages ( signInTitle : 'Authentication required' , cancelButton : 'Cancel' , biometricHint : ' ' , ), ], localizedReason : Platform .isAndroid ? 'Touch fingerprint sensor \n ' : ' ' , options : const AuthenticationOptions ( useErrorDialogs : false , stickyAuth : true , biometricOnly : true , sensitiveTransaction : true , ), ); } }
Thanks for the detailed repro and video. I was able to replicate this using S10.
[!] Flutter (Channel stable, 3.22.0, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) ? Flutter version 3.22.0 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ? Upstream repository https://github.com/flutter/flutter.git ? Framework revision 5dcb86f68f (5 days ago), 2024-05-09 07:39:20 -0500 ? Engine revision f6344b75dc ? Dart version 3.4.0 ? DevTools version 2.34.3 ? If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) ? Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. ? CocoaPods version 1.11.2 [?] Chrome - develop for the web ? Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [?] VS Code (version 1.62.0) ? VS Code at /Applications/Visual Studio Code.app/Contents ? Flutter extension version 3.21.0 [?] Connected device (5 available) ? SM G975F (mobile) ? RZ8M802WY0X ? android-arm64 ? Android 11 (API 30) ? Darshan's iphone (mobile) ? 21150b119064aecc249dfcfe05e259197461ce23 ? ios ? iOS 14.4.1 18D61 ? iPhone 12 Pro Max (mobile) ? A5473606-0213-4FD8-BA16-553433949729 ? ios ? com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) ? macOS (desktop) ? macos ? darwin-x64 ? Mac OS X 10.15.4 19E2269 darwin-x64 ? Chrome (web) ? chrome ? web-javascript ? Google Chrome 98.0.4758.80 [?] HTTP Host Availability ? All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.22.0-45.0.pre.3, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) ? Flutter version 3.22.0-45.0.pre.3 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ? Upstream repository https://github.com/flutter/flutter.git ? Framework revision fe0932f2c0 (4 hours ago), 2024-05-22 22:19:25 -0400 ? Engine revision b8b82454e3 ? Dart version 3.5.0 (build 3.5.0-178.0.dev) ? DevTools version 2.36.0-dev.10 ? If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) ? Android SDK at /Users/dhs/Library/Android/sdk ? cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ? Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [?] Xcode - develop for iOS and macOS (Xcode 13.2.1) ? Xcode at /Applications/Xcode.app/Contents/Developer ? Build 13C100 ? CocoaPods version 1.11.2 [?] Chrome - develop for the web ? Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [?] IntelliJ IDEA Ultimate Edition (version 2021.3.2) ? IntelliJ at /Applications/IntelliJ IDEA.app ? Flutter plugin version 65.1.4 ? Dart plugin version 213.7228 [?] VS Code (version 1.62.0) ? VS Code at /Applications/Visual Studio Code.app/Contents ? Flutter extension version 3.29.0 [?] Connected device (3 available) ? Darshan's iphone (mobile) ? 21150b119064aecc249dfcfe05e259197461ce23 ? ios ? iOS 15.3.1 19D52 ? macOS (desktop) ? macos ? darwin-x64 ? macOS 12.2.1 21D62 darwin-x64 ? Chrome (web) ? chrome ? web-javascript ? Google Chrome 109.0.5414.119 [?] Network resources ? All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) ? Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. ? CocoaPods version 1.11.2 [?] Chrome - develop for the web ? Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [?] VS Code (version 1.62.0) ? VS Code at /Applications/Visual Studio Code.app/Contents ? Flutter extension version 3.21.0 [?] Connected device (5 available) ? SM G975F (mobile) ? RZ8M802WY0X ? android-arm64 ? Android 11 (API 30) ? Darshan's iphone (mobile) ? 21150b119064aecc249dfcfe05e259197461ce23 ? ios ? iOS 14.4.1 18D61 ? iPhone 12 Pro Max (mobile) ? A5473606-0213-4FD8-BA16-553433949729 ? ios ? com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) ? macOS (desktop) ? macos ? darwin-x64 ? Mac OS X 10.15.4 19E2269 darwin-x64 ? Chrome (web) ? chrome ? web-javascript ? Google Chrome 98.0.4758.80 [?] HTTP Host Availability ? All required HTTP hosts are available ! Doctor found issues in 1 category.
This is likely an issue in the underlying library given that the initial result demonstrates that we can correctly map the error codes at the plugin layer.
@stuartmorgan does that mean we should close this issue since it is with the underlying library?
Ideally someone should validate that it's not a bug in our logic; I think it's very likely not to be given the symptoms, but a definitive answer from debugging would mean we would either know we could fix this, or know enough that someone could file an issue against the credential manager library.
No branches or pull requests