timetable icon indicating copy to clipboard operation
timetable copied to clipboard

Detect when page in MultiDateTimetable completes

Open ghost opened this issue 2 years ago • 0 comments

How to detect when page completely changes? For example to get a callback not after you just begin with swiping, nor when you release a press while swiping, but when animation of page swipe ends? If you were to start swiping form one page to another and while on the middle between two pages you release a press, page will continue with animation to second page, and when it finishes animation i would like to get a callback.

Reason why I'm asking is because I would like to fetch events from server whenever user swipes to new page, and issue with _dateController.addListener() is because it triggers a callback somewhat good when you swipe to next page, but when you try to swipe to previous page listener is triggered almost instantly as you being to swipe to previous page.

I though to use NotificationListener, and it does work properly for horizontal swiping but issues with this approach is that it also detects when scrolling is active vertically, what i need is only to listen when horizontal page swiping ends

void handleScrollListener(ScrollNotification scrollNotification) {
  if (scrollNotification is ScrollStartNotification) {
    print("SCROLLING");
  } else if (scrollNotification is ScrollEndNotification) {
    print("STOPPED SCROLLING!");
  }
}

@override
Widget build(BuildContext context) {
  return NotificationListener<ScrollNotification>(
    onNotification: (scrollNotification) {
      SchedulerBinding.instance!.addPostFrameCallback(
          (_) => handleScrollListener(scrollNotification));
      return true;
    },
    child: Stack(
      children: [
        TimetableConfig<EventModel>(

ghost avatar Aug 30 '21 13:08 ghost