Dart - NumberFormat

后端 未结 7 999
北荒
北荒 2021-02-19 00:08

Is there a way with NumberFormat to display :

  • \'15\' if double value is 15.00
  • \'15.50\' if double value is 15.50

Thanks for yo

7条回答
  •  时光说笑
    2021-02-19 00:49

    An alternate solution, working on the string output of NumberFormat:

    final f = NumberFormat("###.00");
    print(f.format(15.01).replaceAll('.00', ''));
    print(f.format(15.00).replaceAll('.00', ''));
    

提交回复
热议问题