separateSelected method

List<MultiSelectItem<T>> separateSelected(
  1. List<MultiSelectItem<T>> list
)

Implementation

List<MultiSelectItem<T>> separateSelected(List<MultiSelectItem<T>> list) {
  List<MultiSelectItem<T>> _selectedItems = [];
  List<MultiSelectItem<T>> _nonSelectedItems = [];

  _nonSelectedItems.addAll(list.where((element) => !element.selected));
  _nonSelectedItems.sort((a, b) => a.label.compareTo(b.label));
  _selectedItems.addAll(list.where((element) => element.selected));
  _selectedItems.sort((a, b) => a.label.compareTo(b.label));

  return [..._selectedItems, ..._nonSelectedItems];
}