DEV Community

Hemunt Sharma
Hemunt Sharma

Posted on

How to add a static widget at the end of ListView In Flutter

Here are some steps

  • First Add LsitView to your code, Make its children

  • Create one Nested Listview Builder For the rest of the Listview elements.

  • Make sure to add Property — (Physics: ScrollPhysics(), shrinkWrap: true) To ListView builder

  • Below that listView builder Create the Footer widget(Container).

  • Wrap the ListView Builder and Footer widget in the children of the First created ListView

  • Below is the Example Code for this

Now I Crested the List of the Rest of the Widgets And the footer Widget was Created Separately

  List listTiles = ["A", "B", "C", "C"];

Enter fullscreen mode Exit fullscreen mode
 ListView(
          children: <Widget>[

            //Rest of the elements
            ListView.builder(
              physics: ScrollPhysics(),
              shrinkWrap: true,
              itemCount: listTiles.length,
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  color: Colors.green,
                  height: 60,
                  child: Center(
                    child: Text(
                      '${listTiles[index]}',
                      style: const TextStyle(color: Colors.black, fontSize: 16),
                    ),
                  ),
                );
              },
            ),

            //Footer widget or other Static Widget after list view
            Container(
              height: 40,
              color: Colors.redAccent,
              child:  const Center(
                child: Text(
                  'Footer',
                  style: TextStyle(color: Colors.white, fontSize: 16),
                ),
              ),
            ),
          ],
        ),

Enter fullscreen mode Exit fullscreen mode

This is Just one way To do it But here is How to add a static widget at end of ListView builder flutter

Top comments (0)