floatToStrF function

String floatToStrF(
  1. double value,
  2. TFloatFormat format,
  3. int precision,
  4. int digits,
)

Implementation

String floatToStrF(double value, TFloatFormat format, int precision, int digits) {
  switch (format) {
    case TFloatFormat.ffFixed:
    case TFloatFormat.ffNumber:
      return value.toStringAsFixed(digits);
    case TFloatFormat.ffCurrency:
      return value.toStringAsFixed(digits);
    case TFloatFormat.ffExponent:
      return value.toStringAsExponential(precision > 0 ? precision - 1 : 6);
    case TFloatFormat.ffGeneral:
      if (value == value.truncateToDouble() &&
          value.abs() < 1e15 &&
          !value.isInfinite) {
        return value.toInt().toString();
      }
      return value.toString();
  }
}