formatPattern method

  1. @override
String formatPattern (
  1. String digits
)
override

format user input with formatter

Implementation

@override
String formatPattern(String digits) {
  final length = digits.length;
  var groupEndIndex = min(4, length);
  var groupStartIndex = 0;
  var result = new StringBuffer();
  for (; groupEndIndex <= length; groupEndIndex += min(4, max(1, length - groupEndIndex))) {
    result.write(digits.substring(groupStartIndex, groupEndIndex));
    if (groupEndIndex < length) {
      result.write(separator);
    }
    groupStartIndex = groupEndIndex;
  }
  return result.toString();
}