Reputation: 335
I am trying to create a chat history like this
Tried with ListView and CustomerScrollView both force the child to take the full horizontal width.
Also tried to nest a fixed size container inside a ListView Child, still display as full length.
How can I achieve this?
Code - where Child Container is a fixed size but forced to take up the whole width of screen.
child: ListView(
shrinkWrap: true,
children: <Widget>[
Container(
color: Colors.red,
width: 20,
height: 40,
),
],
),
Upvotes: 2
Views: 5430
Reputation: 3410
Try adding a padding or margin to your container:
Container(
padding: EdgeInsets.only(right: 10),
// OR
margin: EdgeInsets.only(right: 10),
);
Use EdgeInsets.only(left: 10)
for the opposite.
Upvotes: 9