【问题标题】:The argument type 'num?' can't be assigned to the parameter type 'num'.dart(argument_type_not_assignable)参数类型 'num?'不能分配给参数类型 'num'.dart(argument_type_not_assignable)
【发布时间】:2021-09-15 08:56:25
【问题描述】:

enter image description here

我正在使用财务创建一个贷款计算器:来自 pub.dev/packages/finance 的 ^0.1.0 包。在计算支付的总利息时,我在 c['ipmt'] 处遇到错误。错误是参数类型'num?'不能分配给参数类型 'num'.dart(argument_type_not_assignable)。

请帮忙。

【问题讨论】:

    标签: flutter dart null


    【解决方案1】:

    您的编译器不知道给定的映射包含一个值。作为程序员,你有理由相信,因为你添加了它,但是编译器不够聪明。

    这里的教训是当您确定数据是什么样子时创建一个实际类型。与其属性的映射依赖于您每次访问它们时正确键入它们,不如创建一个具有这些属性的类。那么你的编译器就会知道,此时程序中,这个属性不能为空。

    【讨论】:

      猜你喜欢
      • 2019-04-13
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-10-03
      • 2021-09-16
      • 1970-01-01
      • 2021-09-25
      • 2019-04-23
      相关资源
      最近更新 更多