Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the Flutter local notifications plugin.
Flutter
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await flutterLocalNotificationsPlugin.[1]();
runApp(MyApp());
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using start() or setup() which do not exist.
Forgetting to call initialize before using notifications.
✗ Incorrect
The method to initialize the plugin is called initialize().
2fill in blank
mediumComplete the code to show a simple notification with a title and body.
Flutter
await flutterLocalNotificationsPlugin.show( 0, 'Hello', 'This is a notification', [1] );
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NotificationSettings or other incorrect classes.
Not providing NotificationDetails causes errors.
✗ Incorrect
The show method requires NotificationDetails to specify platform-specific settings.
3fill in blank
hardFix the error in the AndroidNotificationDetails constructor by completing the missing required parameter.
Flutter
const AndroidNotificationDetails( 'channelId', 'channelName', [1] )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using priority instead of importance in AndroidNotificationDetails.
Omitting importance causes runtime errors.
✗ Incorrect
The importance parameter is required to set the notification importance level.
4fill in blank
hardFill both blanks to create a notification channel with high importance and enable vibration.
Flutter
const AndroidNotificationDetails( 'channelId', 'channelName', importance: [1], vibrationPattern: [2] )
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Importance.low for high priority notifications.
Providing incorrect vibration pattern format.
✗ Incorrect
Use Importance.high for strong notification and a vibration pattern array for vibration.
5fill in blank
hardFill all three blanks to schedule a notification 5 seconds from now with a specific channel and title.
Flutter
await flutterLocalNotificationsPlugin.zonedSchedule( 1, [1], 'Scheduled Notification', tz.TZDateTime.now(tz.local).add(const Duration(seconds: [2])), NotificationDetails( android: AndroidNotificationDetails( [3], 'Scheduled Channel', importance: Importance.high ) ), androidAllowWhileIdle: true, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime );
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong channel id string.
Setting wrong delay duration.
Confusing title with channel name.
✗ Incorrect
The title is 'Reminder', the delay is 5 seconds, and the channel id is 'scheduled_channel_id'.