substring function

String substring(
  1. String str,
  2. int start, [
  3. int? end
])

Implementation

String substring(String str, int start, [int? end]) {
  if (end == null) {
    end = start + 1;
  }
  final splitter = new GraphemeSplitter();
  final iterator = splitter.iterateGraphemes(str.substring(start));
  final strBuffer = new StringBuffer();
  for (int i = 0; i < end - start; i++) {
    strBuffer.write(iterator.elementAt(i));
  }
  return strBuffer.toString();
}