A local notification is a message sent by the app itself to the user’s device without needing a server. It appears as an alert, sound, or badge to notify the user about something important.
Click to reveal answer
beginner
Which Flutter package is commonly used to show local notifications?
The flutter_local_notifications package is commonly used to create and display local notifications in Flutter apps.
Click to reveal answer
intermediate
What permission is usually required to show notifications on Android and iOS?
On Android 13 (API 33) and above, the POST_NOTIFICATIONS permission is required. On iOS, the app must request user permission to show notifications.
Click to reveal answer
intermediate
How do you schedule a notification to appear later in Flutter?
You use the flutter_local_notifications plugin’s schedule method, specifying the time when the notification should appear.
Click to reveal answer
intermediate
Why is it important to handle notification taps in your app?
Handling notification taps lets your app respond when the user clicks the notification, such as opening a specific screen or performing an action, improving user experience.
Click to reveal answer
Which Flutter package helps you show local notifications?
Aflutter_local_notifications
Bhttp
Cprovider
Dshared_preferences
✗ Incorrect
flutter_local_notifications is the package designed for local notifications.
What must an iOS app do before showing notifications?
AEnable background fetch
BNothing, notifications work automatically
CRequest user permission
DRegister with Google Play
✗ Incorrect
iOS requires apps to ask the user for permission to show notifications.
What is a local notification?
AA notification that requires internet
BA message sent from a remote server
CA notification that only appears inside the app
DA message sent from the app itself to the device
✗ Incorrect
Local notifications come from the app on the device, not from a server.
How do you make a notification appear at a specific time in Flutter?
AUse the schedule method of flutter_local_notifications
BUse a Timer widget
CUse the Navigator to push a screen
DUse the setState method
✗ Incorrect
Scheduling notifications uses the schedule method from the notifications plugin.
Why handle notification taps in your app?
ATo disable notifications
BTo open a specific screen or perform an action
CTo change the app icon
DTo update the app version
✗ Incorrect
Handling taps lets the app respond meaningfully when the user clicks a notification.
Explain how to set up and show a simple local notification in Flutter.
Think about the steps from adding the package to displaying a notification.
You got /4 concepts.
Describe the differences in notification permissions between Android and iOS.
Consider what the user must allow on each platform.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of local notifications in a Flutter app?
easy
A. To alert users even when the app is closed or in the background
B. To send messages to a server
C. To update the app's UI instantly
D. To change app theme colors automatically
Solution
Step 1: Understand local notifications
Local notifications are alerts shown to users even if the app is not open or running in the background.
Step 2: Compare options
Options B, C, and D describe other app features unrelated to local notifications.
Final Answer:
To alert users even when the app is closed or in the background -> Option A
Quick Check:
Local notifications alert users outside app use = A [OK]
Hint: Local notifications work when app is not active [OK]
Common Mistakes:
Confusing local notifications with server messages
Thinking notifications only work when app is open
Mixing UI updates with notification purpose
2. Which Flutter plugin is commonly used to show local notifications?
easy
A. firebase_messaging
B. flutter_local_notifications
C. provider
D. http
Solution
Step 1: Identify notification plugins
The plugin flutter_local_notifications is designed for local notifications in Flutter apps.
Step 2: Eliminate unrelated plugins
http is for network calls, provider for state management, firebase_messaging for push notifications, not local.
Final Answer:
flutter_local_notifications -> Option B
Quick Check:
Local notifications plugin = flutter_local_notifications [OK]
Hint: Local notifications use flutter_local_notifications plugin [OK]
Common Mistakes:
Choosing firebase_messaging which is for push, not local
Confusing state management plugins with notification plugins
Selecting network plugins by mistake
3. What will happen if you call show() on a local notification without initializing the plugin first?
medium
A. The notification will show normally
B. The notification will show only on Android devices
C. The notification will be delayed by 5 seconds
D. The app will crash or throw an error
Solution
Step 1: Understand plugin initialization
Local notification plugins require initialization before use to set up channels and permissions.
Step 2: Consequence of missing initialization
Calling show() without initialization causes runtime errors or crashes because the plugin is not ready.
Final Answer:
The app will crash or throw an error -> Option D
Quick Check:
Uninitialized plugin causes error/crash = B [OK]
Hint: Always initialize plugin before showing notifications [OK]
Common Mistakes:
Assuming notifications show without initialization
Thinking notifications delay automatically
Believing platform-specific behavior without init
4. Given this code snippet, what is the error?
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Missing initialization here
await flutterLocalNotificationsPlugin.show(
0,
'Hello',
'Welcome to Flutter',
NotificationDetails(
android: AndroidNotificationDetails('channelId', 'channelName')
)
);
}
medium
A. WidgetsFlutterBinding.ensureInitialized() is unnecessary
B. NotificationDetails is not imported
C. Missing call to initialize() before show()
D. Notification ID cannot be zero
Solution
Step 1: Check plugin initialization
The code calls show() without calling initialize() on flutterLocalNotificationsPlugin first.
Step 2: Understand consequences
Without initialize(), the plugin is not ready, causing errors when showing notifications.
Final Answer:
Missing call to initialize() before show() -> Option C
Quick Check:
Initialize plugin before show() = C [OK]
Hint: Always initialize plugin before calling show() [OK]
Common Mistakes:
Ignoring the need to initialize plugin
Thinking zero ID is invalid
Assuming ensureInitialized() replaces plugin init
5. You want to create a local notification channel with high importance and priority on Android. Which code snippet correctly sets this up?
hard
A. AndroidNotificationDetails('channelId', 'channelName', importance: Importance.high, priority: Priority.high)
B. AndroidNotificationDetails('channelId', 'channelName', importance: Importance.low, priority: Priority.min)
C. AndroidNotificationDetails('channelId', 'channelName', importance: Importance.defaultImportance, priority: Priority.defaultPriority)
D. AndroidNotificationDetails('channelId', 'channelName')
Solution
Step 1: Understand importance and priority
High importance and priority make notifications more visible and urgent on Android.
Step 2: Check code options
AndroidNotificationDetails('channelId', 'channelName', importance: Importance.high, priority: Priority.high) sets importance and priority to high, matching the requirement. Others set low, default, or omit these settings.
Final Answer:
AndroidNotificationDetails('channelId', 'channelName', importance: Importance.high, priority: Priority.high) -> Option A
Quick Check:
High importance and priority = AndroidNotificationDetails('channelId', 'channelName', importance: Importance.high, priority: Priority.high) [OK]
Hint: Use Importance.high and Priority.high for urgent notifications [OK]
Common Mistakes:
Leaving importance and priority at default
Using low importance for urgent alerts
Omitting priority setting
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.