repeat method

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

Repeats this string times times, joined by separator.

'ab'.repeat(3, separator: '-') // 'ab-ab-ab'

Implementation

String repeat(int times, {String separator = ''}) {
  if (times <= 0) return '';
  return List.filled(times, this).join(separator);
}