separateWith method

List<Widget> separateWith(
  1. Widget separator
)

Separate elements of a widget list with a separator widget.

If the list length equals to 1, no separator widget will be introduced.

Credits to Jaime Blasco.

Implementation

List<Widget> separateWith(Widget separator) => length <= 1
    ? this
    : sublist(1).fold(
        [first],
        (r, element) => [...r, separator, element],
      );