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.
aku_new_community/lib/extensions/widget_list_ext.dart

42 lines
865 B

// Flutter imports:
import 'package:flutter/material.dart';
// Project imports:
import 'num_ext.dart';
extension WidgetListExt on List<Widget> {
List<Widget> sepWidget({Widget separate}) {
if (this.isEmpty) return [];
return List.generate(this.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() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isEven) {
_newList.add(element);
}
});
return _newList;
}
}
extension EvenListExt<T> on List<T> {
List<T> evenList() {
List<T> _newList = [];
this.forEach((element) {
if (this.indexOf(element).isOdd) {
_newList.add(element);
}
});
return _newList;
}
}