ListView Widget in Flutter

Types of ListViews

 

  • ListView
  • ListView.builder
  • ListView.separated
  • ListView.custom

 

ListView0

 

  • The default constructor of the ListView class.
  • Takes a list of widgets and makes it scrollable.

 

Properties

 

  • anchor
  • cacheExtent
  • center
  • childrenDelegate
  • clipBehavior
  • controller
  • dragstartBehavior
  • itemExtent
  • keyboardDismissBehavior
  • padding
  • physics
  • primary
  • restorationld
  • reverse
  • runtimeType
  • scrollBehavior
  • scrollDirection
  • semanticChildCount
  • shrinkWrap

 

Example 1:

 

import 'package:flutter/material.dart';


void main() => DemoApp();


class DemoApp extends StatefulWidget {

  @override

  State<StatefulWidget> createState() {

    return DemoAppState();

  }

}


class DemoAppState extends State<DemoApp> {

  @override

  Widget build(BuildContext context) {

    return MaterialApp(

      home: Scaffold(

        appBar: AppBar(

          title: const Text("Demo App"),

        ),

        body: ListView(

          children: [

            Container(

              height: 150,

              child: const Text(''),

              color: Colors.greenAccent,

            ),

            Container(

              height: 150,

              child: const Text(''),

              color: Colors.redAccent,

            ),

            Container(

              height: 150,

              child: const Text(''),

              color: Colors.cyanAccent,

            ),

            Container(

              height: 150,

              child: const Text(''),

              color: Colors.pinkAccent,

            ),

            Container(

              height: 150,

              child: const Text(''),

              color: Colors.tealAccent,

            ),

          ],

        ),

      ),

    );

  }

}

 

padding

 

ListView(

          padding: const EdgeInsets.all(20),


physics

 

ListView(

          physics: const NeverScrollableScrollPhysics(),


reverse

 

ListView(

          reverse: true,

 

scrollDirection

 

ListView(

          scrollDirection: Axis.horizontal,


Video Link:

 
Post a Comment (0)
Previous Post Next Post