A list view is a scrollable list that groups several items and displays them one after another in the scroll direction.
A ListView class is used to create a list view. We can use a default constructor to display list of items.
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text('List view')),
        body: ListView(
          children: <Widget>[
            Container(height: 200, color: Colors.green[100]),
            Container(height: 200, color: Colors.green[200]),
            Container(height: 200, color: Colors.green[300]),
            Container(height: 200, color: Colors.green[400]),
            Container(height: 200, color: Colors.green[500]),
          ],
        ));
  }
} 
             
                         
                         
                        
Leave a Comment
Cancel reply