scrollToHeading method
void
scrollToHeading(
- double heading
)
Implementation
void scrollToHeading(double heading) {
if (heading < 0) heading += 360;
double offset = getHeadingOffset(heading);
int duration = max(offset.abs().ceil(), 100) * 5;
//Spin back if out of range
if (scrollOffset > itemCount * itemWidth - width) {
scrollOffset -= 36 * itemWidth;
} else if (scrollOffset < width / 2 + itemWidth) {
scrollOffset += 36 * itemWidth;
}
offset += scrollOffset;
scrollController.animateTo(offset,
duration: Duration(milliseconds: duration), curve: Curves.decelerate);
this.heading = heading;
scrollOffset = offset;
notifyListeners();
}