Protected against bots by Yandex SmartCaptcha. Data processing policy
SingleChildScrollView
Makes a single child that does not fit into the given space scrollable. Suits a form or a page of several blocks when a list of similar rows is not needed.
Type:
single-child
SizedBox height:120
SingleChildScrollView
Column
Text "Line 1"
Text "Line 2"
Text "Line 3"
Text "Line 4"
Text "Line 5"
Text "Line 6"
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
scrollDirection
|
string | vertical |
Direction:
vertical
,
horizontal
|
reverse
|
bool | false | Start scrolling from the end |
physics
|
string | always |
Response to the gesture:
never
,
bouncing
,
clamp
,
always
|
clipBehavior
|
string | hardEdge | Clipping to the bounds |
keyboardDismissBehavior
|
string | manual |
onDrag
— hide the on-screen keyboard while dragging
|
Nested structures
#padding
Padding inside the scroll area.
SizedBox height:120
SingleChildScrollView
#padding all 16
Column spacing:8
Text "Paragraph 1"
Text "Paragraph 2"
Text "Paragraph 3"
Text "Paragraph 4"
Examples
Horizontal scrolling of a row
SingleChildScrollView scrollDirection:horizontal
Row spacing:8
SizedBox width:200 height:80
ColoredBox color:#4f46e5
SizedBox width:200 height:80
ColoredBox color:#7c3aed
SizedBox width:200 height:80
ColoredBox color:#059669
A form that must not hide behind the keyboard
@email:""
@name:""
SingleChildScrollView keyboardDismissBehavior:onDrag
#padding all 16
Column spacing:12 crossAxisAlignment:stretch
TextField value:$name
#decoration labelText:"Name"
TextField value:$email
#decoration labelText:"Email"
Differences between the app and the site
-
scrollDirectionand#paddingwork.reverse,physicsandclipBehaviorare not read on the site;keyboardDismissBehaviormakes no sense there (the page has no on-screen keyboard of its own; the browser closes its own by itself). - Inside, the child's size along the cross axis equals the scroll area, and along the main axis it follows the content.
Best practices
-
A long list of similar rows does not belong here.
SingleChildScrollViewbuilds all the content at once, even the invisible part; for long repeated rows use ListView.builder . -
Put
SingleChildScrollViewinside an element of bounded size (SizedBox,Expanded): otherwise there is nothing to scroll — there is as much space as needed anyway. -
Do not put
Expanded/Spacerinside aSingleChildScrollView: there is no space along the main axis for them to stretch into.