| 1 | String trimTrailingFractionZeros(String value) { |
| 2 | if (!value.contains('.')) { |
| 3 | return value; |
| 4 | } |
| 5 | |
| 6 | var end = value.length; |
| 7 | while (end > 0 && value[end - 1] == "0") { |
| 8 | end--; |
| 9 | } |
| 10 | |
| 11 | final trimmed = end == value.length ? value : value.substring(0, end); |
| 12 | return trimmed.endsWith('.') ? trimmed.substring(0, trimmed.length - 1) : trimmed; |
| 13 | } |