Reputation: 15
I get a String (20.95) from a spreadsheet and need to convert it to Double (20.95).
I tried using the Intl package, using
double.parse(NumberFormat.currency(locale: 'en_US').format(price)
but it always returns the value with a comma.
Error: FormatException: Invalid double 20,95
Upvotes: 0
Views: 85
Reputation: 530
The following code replaces the comma with a point and then parses it to a double.
double.parse(yourString.replaceAll(",", ".")),
Upvotes: 1