W3cubDocs

/Dart 2

movePrevious method

bool movePrevious ()

Move back to the previous element.

Returns true and updates current if successful. Returns false and sets current to null if there is no previous element.

Implementation

bool movePrevious() {
  _nextPosition = _position;
  if (_position == 0) {
    _currentCodePoint = null;
    return false;
  }
  int position = _position - 1;
  int codeUnit = string.codeUnitAt(position);
  if (_isTrailSurrogate(codeUnit) && position > 0) {
    int prevCodeUnit = string.codeUnitAt(position - 1);
    if (_isLeadSurrogate(prevCodeUnit)) {
      _position = position - 1;
      _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit);
      return true;
    }
  }
  _position = position;
  _currentCodePoint = codeUnit;
  return true;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-core/RuneIterator/movePrevious.html