prefix method

String prefix(
  1. String text, [
  2. int count = 1
])

Prepends text to the start of this string, repeated count times.

Useful for adding prefixes, bullet points, or repeated characters at the beginning without manual string building.

Example:

'World'.prefix('Hello ')      // 'Hello World'
'item'.prefix('- ')           // '- item'
'x'.prefix('*', 3)            // '***x'

Implementation

String prefix(String text, [int count = 1]) {
  return '${text * count}$this';
}