Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated packages like material.dart or cupertino_icons.
Forgetting to import the biometric package.
✗ Incorrect
The 'local_auth/local_auth.dart' package provides biometric authentication features in Flutter.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like BiometricAuth.
Confusing the class name with variable names.
✗ Incorrect
The LocalAuthentication class is used to access biometric authentication methods.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The method canCheckBiometrics() returns true if biometric hardware is available and enrolled.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using deprecated or incorrect method names.
Not providing a clear localizedReason string.
✗ Incorrect
The authenticate() method starts the biometric prompt with a reason shown to the user.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names.
Not handling exceptions properly.
✗ Incorrect
The authenticate() method is called with a reason, and success or failure messages are printed accordingly.