sortingEnforcement property

SortingEnforcement sortingEnforcement

Whether the list is will disallow modifications that render it in a state that's not sorted by time. Setting this property to true while the collection is in an unsorted state will raise an exception.

Implementation

SortingEnforcement get sortingEnforcement => _sortingEnforcement;
void sortingEnforcement=(SortingEnforcement value)

Implementation

set sortingEnforcement(SortingEnforcement value) {
  // If unchanged, do nothing.
  if (sortingEnforcement == value) {
    return;
  }

  // Change to not force sorting is always safe.
  if (value == SortingEnforcement.notRequired) {
    _sortingEnforcement = value;
  } else {
    // Change to force sorting -> only safe if the contents are currently
    // sorted, otherwise throw an exception.
    if (!sortedByTime) {
      throw GpsPointsViewSortingException(
          'Cannot switch to force sorting by time if the list is currently unsorted.');
    } else {
      _sortingEnforcement = value;
    }
  }
}