Skip to main content

ScrollView

A scrollable container for content that isn't a list. Wraps a single child and provides scroll behavior.

Basic Usage​

widgets.ScrollView{
Child: widgets.Column{
Children: []core.Widget{
header,
content,
footer,
},
},
}

Properties​

PropertyTypeDescription
Childcore.WidgetScrollable content
ScrollDirectionAxisScroll axis (default vertical)
Controller*ScrollControllerOptional scroll controller
PhysicsScrollPhysicsScroll behavior (bounce or clamp)
Paddinglayout.EdgeInsetsPadding around scrollable content

Scroll Physics​

Control scroll behavior when reaching the edges:

widgets.ScrollView{
Physics: widgets.BouncingScrollPhysics{}, // iOS-style bounce
Child: content,
}

widgets.ScrollView{
Physics: widgets.ClampingScrollPhysics{}, // Android-style clamp
Child: content,
}
PhysicsBehavior
BouncingScrollPhysicsBounces when reaching edges (iOS style)
ClampingScrollPhysicsClamps at edges (Android style, default)

Custom Scroll Physics​

Implement the ScrollPhysics interface to define custom scroll behavior. Return true from AllowsOverscroll() to enable overscroll with spring-back animation:

type MyCustomPhysics struct{}

func (MyCustomPhysics) ApplyPhysicsToUserOffset(pos *widgets.ScrollPosition, offset float64) float64 {
return offset
}

func (MyCustomPhysics) ApplyBoundaryConditions(pos *widgets.ScrollPosition, value float64) float64 {
return 0
}

func (MyCustomPhysics) AllowsOverscroll() bool { return true }
  • ListView for scrollable lists of items
  • SafeArea for avoiding system UI in scrollable content