- 此问题在此处已有答案**:
How do you round a double in Dart to a given degree of precision AFTER the decimal point?(28个答案)
2天前关闭。
此帖子已在2天前编辑并提交审核,无法重新打开帖子:
原始关闭原因未解决
double? dTemprature = weather.temperature?.celsius;
sTemprature = dTemprature.toString();
List<String> list = sTemprature.split('.');
sTemprature = list[0] + "." + list[1].substring(0,1);
print ("Weather Temperature: "+sTemprature.toString());
它的未来26.4000000000000我想要2.4
1条答案
按热度按时间rdlzhqv91#
您可以尝试以下方法
double number = double.parse(sTemprature.toStringAsFixed(1));