ReinBentdal / styled_widget

Simplifying widget style in Flutter.
https://pub.dev/packages/styled_widget
MIT License
1.27k stars 103 forks source link

Add support for (toColumn/toRow).separator #38

Closed esDotDev closed 4 years ago

esDotDev commented 4 years ago

Would it be possible to add a separator builder, so we can do something like:

[
   Text(),
   Text(),
].toColumn(separator: ()=>SizedBox(height: 8))
ReinBentdal commented 4 years ago

I will keep this open for now until i have investigated the possibilities!

ReinBentdal commented 4 years ago

Its easy to implement

children: spacer == null
  ? children
  : children.expand((child) => [child, seperator]).toList(),

Will add it in the next release!

esDotDev commented 4 years ago

Oh nice, that's way cleaner than my implementation! Thanks!

(Only thing is, we don't really want it on the end, easy enough to add padding to the start/end as needed)

ReinBentdal commented 4 years ago

Do you mean:

Widget(),
Seperator(),
Widget(),
Seperator (), // remove this

That should be added. Easy to just pop the last element with .removeLast().

esDotDev commented 4 years ago

Yes exactly, from usage, that is almost always what I want to do. We can easily tack on some padding to the start and end with .padding() and it's more readable as well.

This mimics ListView.separated() as well: https://api.flutter.dev/flutter/widgets/ListView/ListView.separated.html

ReinBentdal commented 4 years ago

added in v. 0.2.1