[EDIT Solution]: there was a missing expanded around the ListView that was causing problems and errors. Thanks to all for your valuable inputs and Happy Easter!
I am trying to obtain a layout as in the below image.
Inside a SingleChildScrollview, I have an overall row with two children inside:
- A list of widgets [it can be a listview or a for(int i=0;i<…;i++) widget() ] whose height is unknown ant that it should take all the available width
- A single button that should be vertically centered and taking as little space as possible.
I have been trying out different solutions but I run in errors over errors as everything is inside a SingleChildScrollView and Expanded Widgets require a fixed height, which I don’t have as I don’t know the height of the list of widgets and IntrinsicHeight doesn’t seem to work.
I also bumped into the boxy package ( https://pub.dev/documentation/boxy/latest/ ) which helped to solve to vertically center the iconbutton but there is still the problem about the list of widgets taking as much width as possible.
Recap of nested widgets
SingleChildScrollView(
child: Column(
children: [ ...,
Row(
children:[
List of widgets, //should be taking as much width as possible but height is unknown
IconButton() //should be vertically centered taking as little width as possible
]
)
]
)
)
Can anyone kindly help me?
Thanks a lot in advance and happy Easter
2
Answers
if it’s a list without many items, you can use an expanded together with shrinkWrap as true in the list, check if it’s something like that you want
Simply wrap your
ListView
inExpanded
. You don’t needSingleChildScrollView
, sinceListView
handles the scrolling.