Eray Erdin
Eray Erdin

Reputation: 3159

Flutter: Drawer ListView Body Overflows

Here is a minimum reproducible example.

The drawer in the given example has three parts:

I'd like header and footer visible at all times and would like body to be scrollable, ListView is viable for this.

However, as the children of the ListView grows, it increases its height as well, causing (i) height overflow and (ii) taking the footer down with itself.

How can I fix the size of the body to be until footer at maximum?

Thanks in advance.


Environment

Upvotes: 0

Views: 238

Answers (1)

Eray Erdin
Eray Erdin

Reputation: 3159

At first, I have thought grouping Header and Body as one was a good idea since they should be separated with spaceBetween from footer. However, keeping all of them under one Column with the exception that Body is wrapped with Expanded solves both issue.

So the final solution is:

children: const [
  _DrawerHeader(),
  Expanded(child: _DrawerBody()),
  _DrawerFooter(),
],

With this method, Body occupies all the area it requires.

Upvotes: 1

Related Questions