Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line push notification flutter

Tags:

flutter

dart

I am using the flutter_local_notifications package for push notifications. But in a notification tray, I want to show the complete message, no matter how many lines it takes. This is the code I have written

void showNotification(message) async {
    var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      Platform.isAndroid ? 'com.headstrt.app' : 'com.headstrt.app',
      'Flutter chat demo',
      'your channel description',
      playSound: true,
      enableVibration: true,
      importance: Importance.Max,
      priority: Priority.High,
      styleInformation: BigTextStyleInformation(''),
    );

I have specified a style also but still, all lines are not being displayed.

enter image description here

like image 862
ali262883 Avatar asked Oct 29 '25 08:10

ali262883


2 Answers

In BigTextStyleInformation, you must specify the message value passed to the showNotification function.

my own code as an example;

  Future<void> _demoNotification(Map<String, dynamic> icerik) async {

  String longdata = icerik["notification"]["body"];

  var bigTextStyleInformation = BigTextStyleInformation(longdata); //multi-line show style

 AndroidNotificationDetails androidPlatformChannelSpecifics =
 AndroidNotificationDetails(

        'push_messages: 0',
        'push_messages: push_messages',
        'push_messages: A new Flutter project',
        importance: Importance.max,
        priority: Priority.high,
        showWhen: false,
        enableVibration: true,
        styleInformation: bigTextStyleInformation);

NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);

await flutterLocalNotificationsPlugin.show(
    1,
    icerik["notification"]["title"],
    icerik["notification"]["body"],
    platformChannelSpecifics,
    payload: icerik['data']['routing']);

    }
like image 71
eyponder Avatar answered Oct 31 '25 00:10

eyponder


It's actually not really up to you. In Android, the default for a single notification is on line. If you want to see the entire message you need to drag the notification down.

like image 33
bpedazur Avatar answered Oct 31 '25 00:10

bpedazur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!