intersperse<T> function
courtesy of @modulovalue (https://github.com/modulovalue/dart_intersperse/blob/master/lib/src/intersperse.dart) intersperses elements in between list items - used to insert dividers between toolbar buttons when using ToolbarType.nativeScrollable
Implementation
Iterable<T> intersperse<T>(T element, Iterable<T> iterable) sync* {
final iterator = iterable.iterator;
if (iterator.moveNext()) {
yield iterator.current;
while (iterator.moveNext()) {
yield element;
yield iterator.current;
}
}
}