round_decimal_places method
Tokens
round_decimal_places(
- int round_decimal_places
)
Implementation
Tokens round_decimal_places(int round_decimal_places) {
List<String> tokens_string_split = this.toString().split('.');
if (tokens_string_split.length <= 1) {
return this;
}
String decimal_places_string = tokens_string_split[1];
if (round_decimal_places >= decimal_places_string.length) {
return this;
}
String decimal_places_split_at_round = decimal_places_string.substring(0, round_decimal_places);
return Tokens.of_the_double_string('${tokens_string_split[0]}.${decimal_places_split_at_round}', decimal_places: this.decimal_places);
}