【问题标题】:Flutter listener error The argument Type can't be assigned to the parameter typeFlutter listener error The argument Type can't be assigned to the parameter type
【发布时间】:2022-01-12 21:23:53
【问题描述】:

我开始学习 Flutter,并且我正在编写一个包含一些广告的应用程序,例如来自 AdMob 的插页式广告。

我在 YouTube 视频中指导自己 this is the video 但它显示了这个错误:

The argument type 'void Function(AdmobAdEvent, Map<String, dynamic>)' can't be assigned to the parameter type 'void Function(AdmobAdEvent, Map<String, dynamic>?)?'

我想知道如何解决这个问题

【问题讨论】:

  • 您的教程已经过时,可能已经超过一两年了。阅读 dart 中的 null 安全性,这是大约一年前出现的一项很棒的功能,并且在那之前就处于开发渠道中。
  • 谢谢兄弟,我会检查的

标签: flutter dart admob listener


【解决方案1】:

如错误中所述,你可以改成这个

listener: (AdmobAdEvent event, Map<String, dynamic>? args) { }

【讨论】:

    【解决方案2】:

    就像 nvoigt 所说,教程已经过时,这是一个空的安全相关错误。

    在这种情况下,在dynamic 之后使用? 可能会起作用

    listener: (AdmobAdEvent event, Map<Stringm, dynamic?>) args {} 
    

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 2023-01-27
      • 2022-12-01
      • 2022-12-26
      • 1970-01-01
      • 2022-01-09
      • 2022-08-16
      • 2012-02-03
      • 1970-01-01
      相关资源
      最近更新 更多