is it possible in `NotificationListener<DraggableScrollableNotification>` identify what kind of is it?

Viewed 39

is it possible to determine that the user's scrolling is over, so as not to call the method on each frame

NotificationListener<DraggableScrollableNotification>(
                    onNotification: (notification) {
                      // here determine if scroll is over and func.call()
                    },
                    child: DraggableScrollableSheet(
                      initialChildSize: _initialChildSize,
                      snap: true,
                      snapSizes: _snapSizes,
                      minChildSize: _minChildSize,
                      maxChildSize: _maxChildSize,
                      controller: _sheetController,
                      builder: (context, controller) {
                        return _customScrollView();
                      },
                    ),
                  ),
1 Answers

You can use these if else checks for start, update and end notifications based on user scroll in this way . Please define your own _onStartScroll, _onUpdateScroll, _onEndScroll functions

     if (notification is ScrollStartNotification) {
        _onStartScroll(notification.metrics);
      } else if (notification is ScrollUpdateNotification) {
        _onUpdateScroll(notification.metrics);
      } else if (notification is ScrollEndNotification) {
        _onEndScroll(notification.metrics);
      }

This goes into your function

  onNotification: (notification) {
                      // here determine if scroll is over and func.call()
                    },
Related