Flutter local notification body not showing all notification text (flutter_local_notifications package)
Asked Answered
I

2

25

I used flutter_local_notifications: ^0.7.1+3 in my Flutter app to push schedule notifications. All is well in this but the problem in my notification body is that it shows just one line of text, and I can't expand or stretch notification to show all the notification body text.

This is my try:

class NotificationUtil {
  final notifications = FlutterLocalNotificationsPlugin();
  final int checkOutNotifyId = 0;

  NotificationUtil(BuildContext context) {
    final settingsAndroid = AndroidInitializationSettings('ic_notify_icon');
    final settingsIOS = IOSInitializationSettings(
        onDidReceiveLocalNotification: (id, title, body, payload) =>
            onSelectNotification(context));
    notifications.initialize(
        InitializationSettings(settingsAndroid, settingsIOS),
        onSelectNotification: (context) async => onSelectNotification);
  }

  Future<void> showCheckOutNotify([int maximumCheckoutHours]) async {
    await notifications.periodicallyShow(
        checkOutNotifyId,
        AttendanceConstants.SCHEDULE_NOTIFICATION_TITLE,
        AttendanceConstants.SCHEDULE_NOTIFICATION_BODY +
            '$maximumCheckoutHours Hour/s of your attendance',
        RepeatInterval.Hourly,
        _ongoing);
  }

  NotificationDetails get _ongoing {
    final androidChannelSpecifics = AndroidNotificationDetails(
      'your channel id',
      'your channel name',
      'your channel description',
      importance: Importance.Max,
      priority: Priority.High,
      ongoing: true,
    );
    final iOSChannelSpecifics = IOSNotificationDetails();
    return NotificationDetails(androidChannelSpecifics, iOSChannelSpecifics);
  }
Inlet answered 28/7, 2019 at 9:56 Comment(4)
I found the solution by adding style property: style: AndroidNotificationStyle.BigTextInlet
If you found the solution, how about creating your own answer? You can accept it after 48h.Mauriac
Check out @ahmedel-shafei's solution in his question.Mauriac
What about when my app is closed completely. Talking of when notification is handled by android trayDiacaustic
R
58

add [ BigTextStyleInformation('') ] in [ AndroidNotificationDetails() ]

NotificationDetails get _ongoing {
    final androidChannelSpecifics = AndroidNotificationDetails(
      'your channel id',
      'your channel name',
      'your channel description',
      importance: Importance.Max,
      priority: Priority.High,
      ongoing: true,

      styleInformation: BigTextStyleInformation(''),
    );
Rodrique answered 12/4, 2020 at 23:51 Comment(4)
What about when my app is closed completely. Talking of when notification is handled by android trayDiacaustic
did you find how to display all notification content in the tray? @DiacausticPatriciapatrician
I didn't, so I left the feature. But If you get a solution please share.Diacaustic
Thanks! It worked. I tested it on Android Pie(Version 9).Incontestable
G
2

If anybody is here for the package awesome_notifications, use:

notificationLayout: NotificationLayout.BigText,

inside notification content.

Grafting answered 7/10, 2022 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.