repeat method

String repeat(
  1. int n, {
  2. String separator = '',
})

Returns the given string n times

Implementation

String repeat(int n, {String separator = ''}) {
  if (n < 0) ArgumentError('n must be a positive value greater then 0');

  var repeatedString = '';

  for (var i = 0; i < n; i++) {
    if (i > 0) {
      repeatedString += separator;
    }
    repeatedString += this.validate();
  }

  return repeatedString;
}