Why use ListView.builder instead of ListView?
ListView.builder lazily builds items as they scroll into view.
Display scrollable lists and grids
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
ListView is the go-to widget for displaying scrollable lists of content in Flutter. There are three main ways to create a ListView, each suited for different use cases.
1// 1. ListView with children (for small, fixed lists)2ListView(3children: [4ListTile(title: Text('Item 1')),5ListTile(title: Text('Item 2')),6ListTile(title: Text('Item 3')),7],8)910// 2. ListView.builder (for large/dynamic lists - RECOMMENDED)11ListView.builder(12itemCount: items.length,13itemBuilder: (context, index) {14return ListTile(15title: Text(items[index]),16);17},18)1920// 3. ListView.separated (with dividers)21ListView.separated(22itemCount: items.length,23itemBuilder: (context, index) => ListTile(title: Text(items[index])),24separatorBuilder: (context, index) => Divider(),25)
For lists with many items, the .builder constructor only creates the widgets that are currently visible on screen. This saves memory and significantly improves scrolling performance.
ListTile is a pre-built convenience widget designed specifically for list items. It provides a consistent layout with leading, title, subtitle, and trailing slots.
1ListTile(2leading: CircleAvatar(child: Text('A')),3title: Text('Title'),4subtitle: Text('Subtitle'),5trailing: Icon(Icons.arrow_forward),6onTap: () {7print('Tapped!');8},9)
GridView displays items in a two-dimensional grid layout. It is perfect for image galleries, product catalogs, and any content that benefits from a grid arrangement.
1// Fixed column count2GridView.count(3crossAxisCount: 2, // 2 columns4children: [5Container(color: Colors.red),6Container(color: Colors.blue),7Container(color: Colors.green),8Container(color: Colors.yellow),9],10)1112// GridView.builder (for large lists)13GridView.builder(14gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(15crossAxisCount: 3,16crossAxisSpacing: 10,17mainAxisSpacing: 10,18childAspectRatio: 1, // width/height ratio19),20itemCount: products.length,21itemBuilder: (context, index) {22return ProductCard(products[index]);23},24)
By default, ListView scrolls vertically. You can change the scroll direction to horizontal by setting the scrollDirection property. This is commonly used for horizontal carousels and category chips.
1// Horizontal ListView2ListView.builder(3scrollDirection: Axis.horizontal,4itemCount: items.length,5itemBuilder: (context, index) {6return Container(7width: 150,8margin: EdgeInsets.all(8),9child: Card(child: Center(child: Text(items[index]))),10);11},12)1314// Note: Wrap in SizedBox or Container with fixed height15SizedBox(16height: 200,17child: ListView.builder(18scrollDirection: Axis.horizontal,19...20),21)
Use lazy builders for dynamic collections by default.
For each collection screen, define:
High-quality list screens are not only about rendering items. They are about complete data-state handling.
Display scrollable lists and grids. Widgets are reusable UI blocks. You combine them like LEGO pieces to build screens.
Build confidence with basics first; speed comes later.
Sketch the widget tree first, then code from top to bottom.
Most Flutter productivity comes from understanding layout rules and composing widgets cleanly.
ListView.builder lazily builds items as they scroll into view.
crossAxisCount sets the number of columns in a vertical GridView.
scrollDirection property controls scroll direction.
leading is the widget before the title, trailing is after.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue