Dart 省道双型不';不允许固定格式

Dart 省道双型不';不允许固定格式,dart,double,Dart,Double,我输出以下代码: [v.bankClosingBalance, 0.00].firstWhere((value) => value != null) 和获取错误: Exception: Uncaught Error: type 'double' is not a subtype of type 'String' of 'value'. 这很好,因为它告诉我这是双倍的。问题是作为替身,我应该能够做到: [v.bankClosingBalance, 0.00].firstWhere((va

我输出以下代码:

[v.bankClosingBalance, 0.00].firstWhere((value) => value != null)
和获取错误:

Exception: Uncaught Error: type 'double' is not a subtype of type 'String' of 'value'.
这很好,因为它告诉我这是双倍的。问题是作为替身,我应该能够做到:

[v.bankClosingBalance, 0.00].firstWhere((value) => value != null).toStringAsFixed(2)
但这给了我一个错误:

Exception: Uncaught Error: type 'int' is not a subtype of type 'String' of 'value'.
如果我在它周围使用double.parse,除了“double”之外,它仍然表示相同


我在这里遗漏了什么?

我很确定
v.bankClosingBalance
不会返回您期望的结果。

我无法重现这个问题。

v.bankClosingBalance返回什么?@GünterZöchbauer要么为空,要么为双精度。班级月{双倍银行结余;/*…*/}是的,我的错。我离开了,回来了,重新加载了脚本,效果很好。学童错误!谢谢你调查这件事。