如何将 Dart/Flutter 中的数字从 20,95 转换为 20.95?

How to convert a number from 20,95 to 20.95 in Dart/Flutter?

我从电子表格中得到一个字符串 (20.95),需要将其转换为双精度 (20.95)。

我尝试使用 Intl 包,使用

double.parse(NumberFormat.currency(locale: 'en_US').format(price)

但它总是 returns 带逗号的值。

Error: FormatException: Invalid double 20,95

以下代码将逗号替换为点,然后将其解析为双精度。

double.parse(yourString.replaceAll(",", ".")),