Question #322EasyWidgets & UI

What is the purpose of the SingleChildScrollView widget in Flutter?

#widget#scrolling#layout

Answer

Overview

text
SingleChildScrollView
makes a single widget scrollable. It's used when you have a widget (typically a
text
Column
) that might overflow the screen — but you don't need the lazy loading of
text
ListView
.


Basic Usage

dart
SingleChildScrollView(
  child: Column(
    children: [
      Text('Section 1'),
      SizedBox(height: 300, child: Container(color: Colors.blue)),
      Text('Section 2'),
      SizedBox(height: 300, child: Container(color: Colors.red)),
      Text('Section 3'),
    ],
  ),
)

Scroll Directions

dart
// Vertical scroll (default)
SingleChildScrollView(
  scrollDirection: Axis.vertical,
  child: Column(children: [...]),
)

// Horizontal scroll
SingleChildScrollView(
  scrollDirection: Axis.horizontal,
  child: Row(children: [...]),
)

Common Pattern: Form Screen

dart
Scaffold(
  body: SafeArea(
    child: SingleChildScrollView(
      padding: EdgeInsets.all(16),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          TextFormField(decoration: InputDecoration(labelText: 'Name')),
          SizedBox(height: 16),
          TextFormField(decoration: InputDecoration(labelText: 'Email')),
          SizedBox(height: 16),
          TextFormField(decoration: InputDecoration(labelText: 'Password')),
          SizedBox(height: 24),
          ElevatedButton(onPressed: () {}, child: Text('Submit')),
        ],
      ),
    ),
  ),
)

With ScrollController

dart
final ScrollController _scrollController = ScrollController();

SingleChildScrollView(
  controller: _scrollController,
  child: Column(children: [...]),
)

// Scroll to top
_scrollController.animateTo(0,
  duration: Duration(milliseconds: 300),
  curve: Curves.easeOut,
);

SingleChildScrollView vs ListView

FeatureSingleChildScrollViewListView
Number of childrenOne child (often a Column)Many children
Lazy rendering❌ No — renders all at once✅ Yes — renders only visible
Performance❌ Poor for long lists✅ Good for long lists
Use caseForm screens, small contentDynamic/long lists
Content typeArbitrary layoutRepeated list items

Best Practice: Use

text
SingleChildScrollView
for forms and short screens where all content is known. Use
text
ListView.builder
for dynamic or long lists.