format method

String format (
  1. num value,
  2. {bool formatted: false}
)

Returns a value as String without decimals if possible. Ex. (1, 1.2, .2)

Implementation

String format(num value, {bool formatted = false}) {
  final _value = formatted ? value : adjustPrecision(value);

  if (tryInt && _value == _value.toInt()) return _value.toInt().toString();

  var result = _value.toString();
  if (removeLeadingZero && result.startsWith('0.')) {
    result = result.replaceFirst('0.', '.');
  }

  return result;
}