2014-10-08 63 views
0

I輸出下面的代碼:鏢雙倍類型不允許固定的格式

[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) 

但給我的錯誤:如果我使用double.parse周圍

Exception: Uncaught Error: type 'int' is not a subtype of type 'String' of 'value'. 

還在說,除了用相同的「雙」。

我在這裏錯過了什麼?

+0

'v.bankClosingBalance'返回什麼? – 2014-10-08 16:48:15

+0

@GünterZöchbauer無論是一個null或一個雙。 class Month {double bankClosingBalance;/* ... * /} – khany 2014-10-08 20:04:07

回答

1

我很肯定v.bankClosingBalance不會返回你所期望的。
我無法重現此問題。

+0

耶我的壞。我走了,回來了,重新加載腳本,它運行良好。學校男孩錯誤!感謝您對此進行調查。 – khany 2014-10-09 09:00:15

+0

船舶發生;-) – 2014-10-09 09:01:15