【问题标题】:How can access json in dart in following response如何在以下响应中访问 dart 中的 json
【发布时间】:2021-01-04 14:58:58
【问题描述】:

我正在尝试在以下 json 中访问重定向 url

尝试使用print('on launch ${message['data'].redirect_url}');

但出现运行时错误。

这是进入 message['data'] =>

的响应
  I/flutter (23626): on launch {type: api-testing, click_action: FLUTTER_NOTIFICATION_CLICK, redirect_url: https://google.com}

我怎样才能只访问作为字符串的重定向 URL?

【问题讨论】:

  • message['data']的数据类型是什么?
  • onMessage: (Map message) async { print('on launch ${message['data']}');打印('*************1'); print('关于消息 $message'); },
  • 看看上面的代码你就会明白
  • 你能发布print(message['data'].runtimeType);的输出吗?

标签: flutter dart


【解决方案1】:

您在Map 中将数据作为键传递,您错了。您正在解析 redirectUrl 键,因此您必须使用 redirectUrl 作为地图中的键我的意思是说:

Message['redirecturl']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-17
    • 2021-08-26
    • 2019-08-19
    • 2020-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多