Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    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

    • scrollDirection and #padding work. reverse , physics and clipBehavior are not read on the site; keyboardDismissBehavior makes 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. SingleChildScrollView builds all the content at once, even the invisible part; for long repeated rows use ListView.builder .
    • Put SingleChildScrollView inside 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 / Spacer inside a SingleChildScrollView : there is no space along the main axis for them to stretch into.

    See also

    • ListView — scrolling a list of similar rows
    • Column , Row — typical content
    • ReeelScroll — scrolling with focus for a remote control