问题
I have a problem that only the first line in the notification body appears, how can I make the notification expanded with large content?
This is the code, using the flutter_local_notifications package:
void showNotification(int id, String title, String content, DateTime time) async {
final AndroidNotificationDetails android = AndroidNotificationDetails(
'ch_ID', 'Ch_Name', 'ch_Description',
priority: Priority.High, importance: Importance.Max);
final IOSNotificationDetails ios = IOSNotificationDetails();
final NotificationDetails platform = NotificationDetails(android, ios);
await flutterLocalNotificationsPlugin.schedule(
id,
'$title',
'$content',
time,
platform,
payload: 'payload'
);
}
回答1:
As mentioned in a comment in this other very similar StackOverflow question, you can set the styleInformation
parameter with other classes to format your text. One of these is BigTextStyleInformation
, which implements the DefaultTextStyleInformation
, which is also an implementation of the abstract class StyleInformation
.
final AndroidNotificationDetails android = AndroidNotificationDetails(
'ch_ID',
'Ch_Name',
'ch_Description',
priority: Priority.High,
importance: Importance.Max,
// add this line in your code
styleInformation: BigTextStyleInformation(''),
);
来源:https://stackoverflow.com/questions/61156520/how-to-show-more-than-one-line-in-a-notification-message-flutter-local-notifica