0
0
Fluttermobile~10 mins

Biometric authentication in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the package needed for biometric authentication in Flutter.

Flutter
import '[1]';
Drag options to blanks, or click blank then click option'
Acupertino_icons/cupertino_icons.dart
Bflutter/material.dart
Cdart:async
Dlocal_auth/local_auth.dart
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated packages like material.dart or cupertino_icons.
Forgetting to import the biometric package.
2fill in blank
medium

Complete the code to create an instance of the LocalAuthentication class.

Flutter
final LocalAuthentication auth = [1]();
Drag options to blanks, or click blank then click option'
ABiometricAuth
BLocalAuthentication
CAuthLocal
DAuthenticationLocal
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like BiometricAuth.
Confusing the class name with variable names.
3fill in blank
hard

Fix the error in the code to check if biometric authentication is available.

Flutter
bool canCheck = await auth.[1]();
Drag options to blanks, or click blank then click option'
AcanCheckBiometrics
BisDeviceSupported
Cauthenticate
DcheckBiometrics
Attempts:
3 left
💡 Hint
Common Mistakes
Using authenticate() which starts the authentication process instead of checking availability.
Using isDeviceSupported() which checks device support but not biometric enrollment.
4fill in blank
hard

Fill both blanks to start biometric authentication with a localized reason and options.

Flutter
bool authenticated = await auth.[1](
  localizedReason: '[2]',
  options: const AuthenticationOptions(
    stickyAuth: true,
  ),
);
Drag options to blanks, or click blank then click option'
Aauthenticate
BauthenticateWithBiometrics
CstartAuthentication
DPlease authenticate to proceed
Attempts:
3 left
💡 Hint
Common Mistakes
Using deprecated or incorrect method names.
Not providing a clear localizedReason string.
5fill in blank
hard

Fill all three blanks to handle authentication failure and success with messages.

Flutter
try {
  bool success = await auth.[1](
    localizedReason: '[2]',
  );
  if (success) {
    print('[3]');
  } else {
    print('Authentication failed');
  }
} catch (e) {
  print('Error: $e');
}
Drag options to blanks, or click blank then click option'
Aauthenticate
BPlease verify your identity
CAuthentication successful
DauthenticateWithBiometrics
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names.
Not handling exceptions properly.