convert static method

String convert(
  1. int number
)

Implementation

static String convert(int number) {
  if (number == 0) return "nol";
  if (number < 0) return "minus ${convert(-number)}";

  int thousandIndex = 0;
  String words = "";

  while (number > 0) {
    int remainder = number % 1000;
    if (remainder != 0) {
      String part = _convertHundreds(remainder);
      words = part +
          (thousandIndex > 0 ? " ${_thousands[thousandIndex]}" : "") +
          " " +
          words;
    }
    thousandIndex++;
    number ~/= 1000;
  }

  return words.trim();
}