I'm wondering if I can implement local notification in flutter web? I saw that I can create local notification for mobile app Android or IOS but is it possible to use it for web app? or any other alternative to accomplish it?
Asked
Active
Viewed 747 times
1 Answers
1
Just use the class Notification
in dart:html
package. You can do something like this:
import 'dart:html' as web;
Future<void> showNotification( String message ) async {
var permission = web.Notification.permission;
if (permission != 'granted') {
permission = await web.Notification.requestPermission();
}
if (permission == 'granted') {
web.Notification( message );
}
}
More info about the javascript notification API here: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API

jglatre
- 911
- 1
- 12
- 15
-
It's not working for me I don't understand why :( – Youcef EL KAMEL Apr 07 '23 at 21:57
-
1@YoucefELKAMEL do you get any error or simply it does nothing? – jglatre May 30 '23 at 13:28
-
Nothing happend, I don't understand why... Do You know how I can have some log or something ? I check the dev console JS their is nothing trigger. – Youcef EL KAMEL May 31 '23 at 15:32