insert method

String insert(
  1. String other,
  2. int index
)

Returns a copy of this with other inserted starting at index.

Example:

'word'.insert('s', 0); // 'sword'
'word'.insert('ke', 3); // 'worked'
'word'.insert('y', 4); // 'wordy'

Implementation

String insert(String other, int index) => (StringBuffer()
      ..write(substring(0, index))
      ..write(other)
      ..write(substring(index)))
    .toString();