startTimer method
void
startTimer()
Implementation
void startTimer() {
if (_key.currentContext != null) {
final double widgetWidth = _key.currentContext!.findRenderObject()!.paintBounds.size.width;
final double widgetHeight = _key.currentContext!.findRenderObject()!.paintBounds.size.height;
timer = Timer.periodic(Duration(milliseconds: _timerRest), (final Timer timer) {
final double maxScrollExtent = scrollController.position.maxScrollExtent;
final double pixels = scrollController.position.pixels;
if (pixels + _moveDistance >= maxScrollExtent) {
if (widget.scrollAxis == Axis.horizontal) {
position = (maxScrollExtent - screenWidth! * widget.ratioOfBlankToScreen + widgetWidth) / 2 - widgetWidth + pixels - maxScrollExtent;
} else {
position = (maxScrollExtent - screenHeight! * widget.ratioOfBlankToScreen + widgetHeight) / 2 - widgetHeight + pixels - maxScrollExtent;
}
scrollController.jumpTo(position);
}
position += _moveDistance;
scrollController.animateTo(position, duration: Duration(milliseconds: _timerRest), curve: Curves.linear);
});
}
}