joinWithSeparator method

List<Widget> joinWithSeparator(
  1. Widget separator
)

Adds a specific type of Widget in between a list of Widgets This can be usefull to add some height in between Widgets without the need of writing it multiple times

Example:

[
 const Text('BASF'),
 const Text('MOBILE SOLUTIONS'),
].joinWithSeparator(const SizedBox(height: 10));

Implementation

List<Widget> joinWithSeparator(Widget separator) {
  return length > 1
      ? (take(length - 1)
          .map((widget) => [widget, separator])
          .expand((widget) => widget)
          .toList()
        ..add(last))
      : this;
}