formattingRp function

String formattingRp(
  1. String text
)

Implementation

String formattingRp(String text) {
  String result = "";
  int dot = text.length ~/ 3;
  int extend = text.length % 3;
  int position = 0;
  for (var i = 0; i <= dot; i++) {
    if (i == 0) {
      result += text.substring(0, extend);
      position = extend;
    } else {
      if (extend == 0) {
        result += text.substring(position, position + 3);
        extend = 1;
      } else {
        result += ".${text.substring(position, position + 3)}";
      }
      position += 3;
    }
  }
  return result;
}