attach method

  1. @override
  2. @internal
void attach(
  1. double extent,
  2. List<FSliderMark> marks
)
override

Registers the controller to a slider with the given extent and marks.

A controller can only be attached to a single slider at a time.

Implementation

@override
@internal
void attach(double extent, List<FSliderMark> marks) {
  assert(marks.isNotEmpty, 'At least one mark is required.');

  final proposed = DiscreteSelection(
    mainAxisExtent: extent,
    extent: selection.extent,
    offset: selection.offset,
    ticks: SplayTreeMap.fromIterable(marks.map((mark) => mark.value), value: (_) {}),
  );

  if (_selection == null) {
    _selection = proposed; // We don't want to notify listeners when performing initialization.
  } else {
    selection = proposed;
  }
}