You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there could be a getter/method that iterates through a list looping/cycling through its elements. My use case was cycling through the items on a String.split(pattern) so I could join them again in different orders.
Implementation
final list = ['A', 'B', 'C'];
for (int i =0; i < list.length; i++) {
final result = [ ...list.sublist(i), ...list.take(i)];
print('$result');
}
Output
[A, B, C]
[B, C, A]
[C, A, B]
The text was updated successfully, but these errors were encountered:
FMorschel
changed the title
Extension .loop method or getter
Extension .loop or .cycle method or getter
Oct 24, 2022
I think there could be a getter/method that iterates through a list looping/cycling through its elements. My use case was cycling through the items on a
String.split(pattern)
so I could join them again in different orders.Implementation
Output
The text was updated successfully, but these errors were encountered: