stateToIndex method
Converts a state index to an offset index.
state: The index of the state.- Returns: The corresponding index in the snapping offsets list.
- Throws: AssertionError if the state index is out of range.
Implementation
int stateToIndex(int state) {
assert(
state >= 0 && state < snappingPixelOffsets.length ||
snappingPixelOffsets.isEmpty,
'Provided state index is out of range for snapping positions. '
'Please ensure unique offsets and valid states.\n'
'State index: $state, Snapping offsets length: ${snappingPixelOffsets.length}\n'
'State offsets: $snappingPixelOffsets\n'
'Min and max offsets: $minOffset : $maxOffset',
);
if (snappingPixelOffsets.isEmpty) {
return 0;
}
return snappingPixelOffsets.length - 1 - state;
}