khany
khany

Reputation: 1187

dart double type doesn't allow fixed format

I output the following code:

[v.bankClosingBalance, 0.00].firstWhere((value) => value != null)

and get error:

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

which is fine as it tells me its a double. Problem is as a double I should be able to do:

[v.bankClosingBalance, 0.00].firstWhere((value) => value != null).toStringAsFixed(2)

but that gives me the error:

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

if I use double.parse around it it still says the same except with 'double'.

What am I missing here?

Upvotes: 0

Views: 189

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657861

I'm pretty sure v.bankClosingBalance doesn't return what you expect.
I wasn't able to reproduce this problem.

Upvotes: 1

Related Questions