Challenge - 5 Problems
Permissions Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when permission is denied in this Flutter code?
Consider this Flutter snippet that requests camera permission. What will the app do if the user denies the permission?
Flutter
import 'package:permission_handler/permission_handler.dart'; Future<void> checkCameraPermission() async { var status = await Permission.camera.status; if (!status.isGranted) { var result = await Permission.camera.request(); if (result.isDenied) { print('Permission denied'); } else if (result.isGranted) { print('Permission granted'); } } else { print('Permission already granted'); } }
Attempts:
2 left
💡 Hint
Think about what the code does when result.isDenied is true.
✗ Incorrect
The code checks if permission is denied and prints 'Permission denied'. It does not crash or retry automatically.
🧠 Conceptual
intermediate1:30remaining
Which permission status indicates the user permanently denied permission?
In Flutter's permission_handler package, which status means the user denied permission and selected 'Don't ask again'?
Attempts:
2 left
💡 Hint
This status means the app cannot request permission again without user action in settings.
✗ Incorrect
PermissionStatus.permanentlyDenied means the user denied permission and chose not to be asked again.
❓ lifecycle
advanced2:00remaining
When should you check permissions in a Flutter app lifecycle?
You want to check and request location permission in your Flutter app. When is the best lifecycle moment to do this to ensure permission is up to date?
Attempts:
2 left
💡 Hint
Permissions can change while app is in background.
✗ Incorrect
Checking permissions on app resume ensures you catch changes made outside the app.
🔧 Debug
advanced2:00remaining
Why does this Flutter permission request code never print 'Permission granted'?
Review this code snippet. It requests microphone permission but never prints 'Permission granted' even when permission is granted.
Flutter
import 'package:permission_handler/permission_handler.dart'; Future<void> requestMic() async { var status = await Permission.microphone.request(); if (status == PermissionStatus.granted) { print('Permission granted'); } else if (status == PermissionStatus.denied) { print('Permission denied'); } }
Attempts:
2 left
💡 Hint
Check the function signature and usage of await.
✗ Incorrect
The function is not async, so await does not pause execution and status is a Future, not PermissionStatus.
expert
2:30remaining
How to navigate user to app settings when permission is permanently denied?
In Flutter, if a user permanently denies camera permission, how can you open the app settings screen so they can manually enable it?
Attempts:
2 left
💡 Hint
permission_handler provides a built-in method for this.
✗ Incorrect
openAppSettings() opens the device app settings screen for your app.