convertFirstCharacters method

String convertFirstCharacters(
  1. String callback(
    1. String
    ), {
  2. int count = 1,
})

Converts the first count characters of this string with callback. If this is shorter than count, this String is returned.

Implementation

String convertFirstCharacters(String Function(String) callback,
    {int count = 1}) {
  final iterator = characters.iterator;
  if (iterator.moveNext(count)) {
    return callback(iterator.stringBefore + iterator.current) +
        iterator.stringAfter;
  }
  return this;
}