Push Notification in Flutter - Local Notification Part -2
Last updated Dec 19, 2021In this Flutter Notification example we will cover how to handle click events of Notification and navigate to other screen when we click on notification. we learned in previous example about how to create Local notification in flutter and display notification on status bar.
In this post we are going to learn Notification Customization like change the color of the notification icon, notification tap events...
We are showing the downloading progress on notification
The default notification showing like below
Now we are going to change the color of Notification and icon
color: Colors.pink |
Now the notification will show like this
autoCancel: Auto cancel Notification
By using this property we can cancel the Notification on click by set value true
How to show the Progress notification
By using the progress property we can achieve this.
In the example i am going to show the notification progress update by every 2 seconds
import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { primarySwatch: Colors.pink, class MyHomePage extends StatefulWidget {
@override class _MyHomePageState extends State { GlobalKey _scaffoldKey = GlobalKey(); print("Initialize 1");
});
var initializationSettingsAndroid =
|
While run the above code the notification will update its progress.
How to Navigation other screen while open Notification
flutterLocalNotificationsPlugin.initialize(initializationSettings, Navigator.push(context, MaterialPageRoute(builder: (context){ return Scaffold( body: Center( |
With the above code on tap on Notification we are Navigating the other Screen.
Conclusion: We covered how to customize flutter local notifications and handle notification click events while open the notification navigate to other screens.
Article Contributed By :
|
|
|
|
3729 Views |