SingleChildScrollView class

A widget that wraps a single child widget and makes it scrollable.

It clips the child's output to the viewport size and shifts the rendering position based on the current scroll offset of the scroll controller.

Example Usage

The following example wraps a vertical column layout containing multiple rows of text, allowing the user to scroll down through the list.

SingleChildScrollView(
  childLength: 100, // Total virtual lines
  scrollDirection: LayoutDirection.vertical,
  controller: myScrollController,
  child: Column([
    for (int i = 0; i < 100; i++)
      SizedBox(height: 1, child: Text('Row #$i')),
  ]),
);

Properties and Settings

Property Type Description
child Widget The nested widget that will be scrolled.
scrollDirection LayoutDirection Scroll orientation (vertical or horizontal).
controller DiscreteScrollController? Scroll state tracker and scroll operations handler.
childLength int The total virtual width/height content offset size.
Inheritance

Constructors

SingleChildScrollView({required Widget child, LayoutDirection scrollDirection = LayoutDirection.vertical, DiscreteScrollController? controller, required int childLength})
Creates a new SingleChildScrollView.
const

Properties

child Widget
The nested widget that will be scrolled.
final
childLength int
The total virtual width/height content offset size.
final
controller DiscreteScrollController?
Scroll state tracker and scroll operations handler.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
The optional key for this widget.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollDirection LayoutDirection
Scroll orientation (vertical or horizontal).
final

Methods

createElement() Element
Creates an Element to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
getIntrinsicHeight(int width) int
Computes the intrinsic height of this widget under the given width constraint.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(Buffer buffer, Rect area) → void
Renders the widget onto the provided buffer within the specified area.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited