repeatString function

String repeatString(
  1. String str,
  2. int n
)

Implementation

String repeatString(String str, int n) {
  if (n == 0) {
    return '';
  } else if (n == 1) {
    return str;
  }
  final strBuf = new StringBuffer();
  for (int i = 0; i < n; i++) {
    strBuf.write(str);
  }
  return strBuf.toString();
}