updateSelection method
bool
updateSelection(
- List<
SeriesDatum< datumSelection,D> > - List<
ImmutableSeries< seriesList, {D> > - bool notifyListeners = true,
Updates the selection state. If mouse driven, datumSelection
should be
ordered by distance from mouse, closest first.
Implementation
bool updateSelection(
List<SeriesDatum<D>> datumSelection,
List<ImmutableSeries<D>> seriesList, {
bool notifyListeners = true,
}) {
if (_locked) return false;
final origSelectedDatum = _selectedDatum;
final origSelectedSeries = _selectedSeries;
_selectedDatum = datumSelection;
_selectedSeries = seriesList;
// Provide a copy, so listeners get an immutable model.
final copyOfSelectionModel = SelectionModel.fromOther(this);
for (final listener in _updatedListeners) {
listener(copyOfSelectionModel);
}
final changed = !ListEquality<SeriesDatum<D>>()
.equals(origSelectedDatum, _selectedDatum) ||
!ListEquality<ImmutableSeries<D>>()
.equals(origSelectedSeries, _selectedSeries);
if (notifyListeners && changed) {
for (final listener in _changedListeners) {
listener(copyOfSelectionModel);
}
}
return changed;
}