Learn how to send notification from flutter local device. Here we will cover the method, the post method to send notification.
Of course it means before that, you must enable other service and write the correct code.
Future<void> sendNotification(String title, String body, String token) async {
final String url = 'https://fcm.googleapis.com/fcm/send';
var notification;
notification =
'{"notification": {"body": "${body}", '
'"title": "${title}",'
' "content_available": "true"},'
' "priority": "high", '
'"to": "${token}",'
'}';
final response = await http.post(
Uri.parse(url),
headers: <String, String>{
"Content-Type": "application/json",
"Keep-Alive": "timeout=5",
"Authorization": "key=AAAAUowPRnI:APA91bE_oiOwbO17ymwzx4bryWViMlO3hTzukVOEcWP-Qqf8yU-eL9i_Joqs6KpaFTYF_Rll6uyi4oZ5ddfwgD4tpphFSzHJTDEYLdjz5S0mDsBl40Yy0IcZVJgNmOiGUxsvLu8AwUcy"
},
body: notification
);
print(response.body);
}