Gap in a ListView

285 views
Skip to first unread message

Chris

unread,
Sep 17, 2018, 2:22:40 PM9/17/18
to Flutter Dev
I have created a horizontal list in flutter and want to add a gap between the items. Is there an easy way to achive this?

Sanjay Tejani

unread,
Sep 17, 2018, 3:08:13 PM9/17/18
to Flutter Dev
Hi Chris,

You have add padding around widget.

Example
 new Container(
            padding: const EdgeInsets.fromLTRB(1.0, 2.0, 1.0, 1.0),
            alignment: Alignment.center,
          ),

Please refer this site https://flutterstudio.app/

Chris

unread,
Sep 17, 2018, 4:07:47 PM9/17/18
to Flutter Dev
Hi Sanjay,

in that case I would habe the gap at the start and end of the list... but I only want the gap between the items.

Harish Balasubramanian

unread,
Sep 17, 2018, 4:11:38 PM9/17/18
to Chris, Flutter Dev
You could put an inline conditional that would allow that.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris

unread,
Sep 17, 2018, 4:20:47 PM9/17/18
to Flutter Dev
Yes... this is working... 

return new Container(
  padding: new EdgeInsets.only(left: index != 0 ? 5.0 : 0.0),
child: new RawMaterialButton(
...

but it feels a little bit strange... Wrapping something in a Widget to add some padding is not a problem to performace in Lists in Flutter?
Reply all
Reply to author
Forward
0 new messages