Метод replaceRange
Заменяет подстроку с start по end на replacement.
Создаёт новую строку, эквивалентную:
this.substring(0, start) + replacement + this.substring(end)
Пример:
const string = 'Dart is fun'; final result = string.replaceRange(8, null, 'open source'); print(result); // Dart is open source
Индексы start и end должны указывать на допустимый диапазон этой строки. То есть 0 <= start <= end <= this.length. Если end равно null, оно по умолчанию равно длине.
Реализация
String replaceRange(int start, int? end, String replacement);
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-core/String/replaceRange.html