0
0
Fluttermobile~20 mins

Biometric authentication in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Biometric Authentication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
Biometric Authentication Button Behavior
What will happen when the user taps the biometric authentication button in this Flutter widget?
Flutter
ElevatedButton(
  onPressed: () async {
    final isAvailable = await auth.canCheckBiometrics;
    if (isAvailable) {
      final authenticated = await auth.authenticate(
        localizedReason: 'Please authenticate to proceed',
        options: const AuthenticationOptions(biometricOnly: true),
      );
      if (authenticated) {
        print('Access granted');
      } else {
        print('Access denied');
      }
    } else {
      print('Biometrics not available');
    }
  },
  child: const Text('Authenticate'),
)
AIt throws a runtime error because authenticate is not awaited.
BIt always prints 'Access granted' without checking biometrics.
CIf biometrics are available, it prompts the user to authenticate and prints 'Access granted' on success.
DIt prints 'Biometrics not available' even if biometrics are enabled.
Attempts:
2 left
💡 Hint
Check the flow: canCheckBiometrics is checked before authenticate is called.
lifecycle
intermediate
1:30remaining
Handling Biometric Authentication State
In a Flutter app using biometric authentication, which lifecycle method is best to check if biometrics are available when the app resumes from background?
AinitState()
BdidChangeAppLifecycleState(AppLifecycleState.resumed)
Cdispose()
Dbuild()
Attempts:
2 left
💡 Hint
Think about when the app returns to the foreground.
📝 Syntax
advanced
1:30remaining
Correct Usage of authenticate() Options
Which option correctly uses the authenticate() method from local_auth package to restrict authentication to biometrics only?
Flutter
final authenticated = await auth.authenticate(
  localizedReason: 'Authenticate',
  options: ???
);
AAuthenticationOptions(biometricOnly: true)
BAuthenticationOptions(biometricOnly: false)
CAuthenticationOptions(stickyAuth: true)
DAuthenticationOptions(useErrorDialogs: false)
Attempts:
2 left
💡 Hint
Look for the option that limits authentication to biometrics.
🔧 Debug
advanced
2:00remaining
Debugging Biometric Authentication Failure
A Flutter app using local_auth package always prints 'Biometrics not available' even on devices with biometrics enabled. What is the most likely cause?
AThe app forgot to add the required permissions in AndroidManifest.xml or Info.plist.
BThe authenticate() method was called without awaiting.
CThe localizedReason string is empty.
DThe app is running on an emulator that supports biometrics.
Attempts:
2 left
💡 Hint
Check platform-specific setup for biometric permissions.
🧠 Conceptual
expert
2:30remaining
Security Implications of Biometric Authentication
Which statement best describes a security consideration when using biometric authentication in mobile apps?
ABiometric authentication guarantees 100% protection against unauthorized access.
BBiometric authentication replaces the need for any fallback authentication method.
CBiometric data is stored and accessible by the app for custom processing.
DBiometric authentication should be combined with fallback methods like PIN for better security.
Attempts:
2 left
💡 Hint
Think about what happens if biometrics fail or are unavailable.