1

In Swift/UIKit, we have the scrollViewWillEndDragging(_:withVelocity:targetContentOffset:) API.

This API gets called when the user finish their drag, as the title suggests, and allows us to set the target offset.

It is useful to disallow scrolling to specific content offsets, for example:

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    if (targetContentOffset.pointee.y > 100 && targetContentOffset.pointee.y < 150) {
        targetContentOffset.pointee.y = 100
    }
}

I would like to know what is the equivalent API in Flutter (ScrollController)

Thanks in advance.

Daisy the cat
  • 372
  • 3
  • 11

0 Answers0