flutter 无法删除小数位[重复]

ttvkxqim  于 2022-12-24  发布在  Flutter
关注(0)|答案(1)|浏览(156)
    • 此问题在此处已有答案**:

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

rdlzhqv9

rdlzhqv91#

您可以尝试以下方法double number = double.parse(sTemprature.toStringAsFixed(1));

相关问题