toggle method

Future toggle(
  1. double range
)

Implementation

Future toggle(double range) async {
  if (scrollController.offset > 0 && scrollController.offset < range) {
    if (scrollAnimateToRunning != null) {
      await scrollAnimateToRunning;
    }

    if (scrollController.offset < range / 2) {
      scrollAnimateToRunning = scrollController.animateTo(0,
          duration: Duration(milliseconds: 100), curve: Curves.ease)
        ..then((value) => scrollController.jumpTo(0));
    } else if (scrollController.offset < range) {
      scrollAnimateToRunning = scrollController.animateTo(range,
          duration: Duration(milliseconds: 100), curve: Curves.ease)
        ..then((value) => scrollController.jumpTo(range));
    }
  }
}