Ali F. Abbas
Ali F. Abbas

Reputation: 61

Flutter | How to add a SizedBox() as the last item of a ListView.builder()?

I'm trying to put some space or a SizedBox() as the last item of the ListView, because the FloatingActionButton() is hiding some information from the last ListTile.

I want to scroll to the space/SizeBox() like WhatsApp for example.

body: ListView.builder(
    itemCount: cardsList.length,
    itemBuilder: (context, i) {
      return Column(
        children: [
          ListTile( ... ),
          Divider( ... ),
        ],
      );
    },
  ),

Upvotes: 3

Views: 2017

Answers (3)

Md. Yeasin Sheikh
Md. Yeasin Sheikh

Reputation: 63749

I think you want this

 ListView.builder(
        itemCount: cardsList.length + 1,
        itemBuilder: (context, index) =>
            index < items.length ? myListTile() : SizedBox(),
      ),

Upvotes: 0

Nagual
Nagual

Reputation: 2088

ListView has padding property

body: ListView.builder(
    padding: const EdgeInsets.only(bottom: 100),
    itemCount: cardsList.length,
    itemBuilder: (context, i) {
      return Column(
        children: [
          ListTile( ... ),
          Divider( ... ),
        ],
      );
    },
  ),

Upvotes: 5

Aloysius Samuel
Aloysius Samuel

Reputation: 1200

You can wrap your ListView with the Column widget. In that widget add the SizedBox. Like this:

body: Column(
  children: [
    ListView.builder(
      itemCount: cardsList.length,
      itemBuilder: (context, i) {
        return Column(
          children: [
            ListTile( ... ),
            Divider( ... ),
          ],
        );
      },
    ),
    SizedBox(height: 50.0)
  ]
)

Upvotes: 1

Related Questions