truncateToDouble() method in my answer auto rounds decimal place based values to 1 when they are less than 1 (i.e. 0.95) which is an unwanted side effect. @alexwan02 use RegExp(r”([.]* 0+)(?!. *\d)”) to remove all trailing zeroes after the decimal point .