多行推送通知颤动

ali*_*883 4 dart flutter

我正在使用 flutter_local_notifications 包进行推送通知。但在通知托盘中,我想显示完整的消息,无论需要多少行。这是我写的代码

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(''),
    );

Run Code Online (Sandbox Code Playgroud)

我也指定了样式,但仍然没有显示所有行。

在此输入图像描述

小智 7

在 BigTextStyleInformation 中,您必须指定传递给 showNotification 函数的消息值。

以我自己的代码为例;

  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']);

    }
Run Code Online (Sandbox Code Playgroud)