Skip to content

Instantly share code, notes, and snippets.

View Kirpal's full-sized avatar
🦄

Kirpal Demian Kirpal

🦄
View GitHub Profile
extension ListExtensions<E> on List<E> {
List<E> interleave(E inserted, {bool insertAtEnd = false}) {
final list = expand((item) => [item, inserted]).toList();
if (!insertAtEnd && list.isNotEmpty) {
list.removeLast();
}
return list;
}
List<E> interleave2(E inserted, {bool insertAtEnd = false}) {
class LoadingState<Data> {
Data? data;
void update({required Data Function() from}) {
data = from();
}
bool get isLoaded => data != null;
}