I am trying to create a same screen like android app note,
here i am getting unexpected extra space as i have given expanded to GridView builder,
how to make gridview’s height based on its content height,
if i remove Expanded its showing unbounded height
i have atteched an image what i am getting from below code ….
Container(
width: 350,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0,
horizontal: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildCreatAccountText(),
buildTextField(),
buildAccountColorTitle(),
Expanded(
child: GridView.builder(
itemCount: colorlist.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8,
mainAxisSpacing: 4,
crossAxisSpacing: 4,
), itemBuilder: (context,index){
return DotContainer();
}),
),
SizedBox(height: 16,),
buildActionButtons(),
],
),
),
)
2
Answers
i was mistaking that i used shrinkWrap with expanded...
i think shrikWrap does not work with Expanded....
I got what i wanted....
Remove Expanded and make shrinkWrap: true (GridView.builder):