Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Physics

Custom scroll physics: making a list stop where you want it to

Scrolling is the interaction users feel most and describe least. “It feels sluggish”, “it doesn’t stop where I expect”, “it bounces wrong on Android”. Those complaints all point at one small class: ScrollPhysics . Most Flutter developers only ever meet it through the three named subclasses — BouncingScrollPhysics , ClampingScrollPhysics , NeverScrollableScrollPhysics . Underneath, it is a compact interface with four decision points, and understanding those turns “the list stops in a weird place” from a mystery into a two-line fix. What the class actually decides Method Decides applyPhysicsToUserOffset How a finger’s movement maps to scroll offset — resistance when overscrolling applyBoundaryConditions How much of a requested offset to refuse at the edges createBallisticSimulation What happens after the finger lifts: fling, settle, snap, or nothing tolerance When a simulation is considered finished Plus two properties worth knowing: shouldAcceptUserOffset (...