You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
809 B

2 years ago
import 'package:flutter/material.dart';
import 'num_ext.dart';
extension WidgetListExt on List<Widget> {
List<Widget> sepWidget({Widget? separate}) {
if (isEmpty) return [];
return List.generate(length * 2 - 1, (index) {
if (index.isEven) {
return this[index ~/ 2];
} else {
return separate ?? 10.wb;
}
});
}
}
extension OddListExt<T> on List<T> {
List<T> oddList() {
2 years ago
List<T> newList = [];
2 years ago
for (var element in this) {
if (indexOf(element).isEven) {
2 years ago
newList.add(element);
2 years ago
}
}
2 years ago
return newList;
2 years ago
}
}
extension EvenListExt<T> on List<T> {
List<T> evenList() {
2 years ago
List<T> newList = [];
2 years ago
forEach((element) {
if (indexOf(element).isOdd) {
2 years ago
newList.add(element);
2 years ago
}
});
2 years ago
return newList;
2 years ago
}
}