ListView Widget

A ListView is a scrollable widget that displays its children one after another in a single column or row. It’s perfect for lists like chat messages, menus, or dynamic data.

Source Code​

				
					import 'package:flutter/material.dart';


class ListV extends StatelessWidget {
  const ListV({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.greenAccent,
        title: Text("List View"),
      ),
      body: ListView(
        children: [
          Container(
            height: 150,
            width: 300,
            color: Colors.red,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.green,

          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.blue,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.orange,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.grey,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.yellow,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.black,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.grey,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.green,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.red,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.blue,
          ),
          Container(
            height: 150,
            width: 300,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.red,
          ),
          Container(
            height: 150,
            width: 300,
            color: Colors.green,
          ),

        ],
      ),
    );
  }
}

				
			

ListView Builder

				
					import 'package:flutter/material.dart';
import 'package:ostadapp/pract1.dart';


class ListV extends StatelessWidget {
  const ListV({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.greenAccent,
        title: Text("List View"),
      ),
      body: ListView.builder(
        itemCount: 50,
        itemBuilder:(context,index){
          return Card(
            child: ListTile(
              leading: Icon(Icons.add_box_sharp),
              trailing: Icon(Icons.delete),
              title: Text("017519164 $index",style: TextStyle(
                color: Colors.red,
                fontSize: 20,
              ),),
            
            ),
          );
        }
      )
    );
  }
}

				
			

Ai Code Analizer

🎨 3. Important Properties

PropertyDescription
scrollDirectionAxis of scrolling: Axis.vertical or Axis.horizontal
paddingInner spacing
itemCountNumber of items (used in builder and separated)
itemBuilderFunction to build each item widget
shrinkWrapReduces height to content (e.g., inside a column)
physicsScroll behavior (e.g., NeverScrollableScrollPhysics)