I want to remove spacing inside my container and I cannot seem to get it right, I tried using height but it still does not work.
my code:
Widget build(BuildContext context) => SizedBox(
height: 440,
child: Container(
//grey color
color: CustomTheme().neutral100,
child: Padding(
padding: const EdgeInsets.fromLTRB(
xxLargePadding, xLargePadding, xxLargePadding, largePadding),
child: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (_, index) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
officials[index].fullName,
style: TextStyle(
fontSize: 12, color: CustomTheme().neutral500),//white color
),
Text(
officials[index].type,
style: TextStyle(
fontSize: 12, color: CustomTheme().neutral400),
),
],
),
separatorBuilder: (_, index) => const Padding(
padding: EdgeInsets.symmetric(vertical: largePadding),
child: Divider(),
),
itemCount: officials.length),
),
),
);
The results looks like the screenshot below:
I want to remove the spacing at the top where I highlighted with red.
There seems to be something making that space, I just do not get it.
Your help will be highly appreciated.
2
Answers
This is because you are using
padding
inside thecontainer
, set0
totop
andbottom
also setlistview
padding to0
:a tip for your code for cleaner code, change your
separatorBuilder
to this:the padding property in the
ListView
takes by default an extra value, you need to set it to 0 like this: