selectable_items
is the package that provides the type SelectableItems
, which encapsulates a list of items and a selected one. Note that it is immutable.
N / A
This package is deprecated.
This package depends on the freezed and freezed_annotation package.
final selectedItems = SelectableItems(
currentIndex: 0,
items: [1, 2, 3, 4, 5],
)
print(selectableItems.currentItem); // 1
final newSelectedItems = selectedItems.selectItem(2);
print(newSelectedItems.currentItem); // 3
By default, insertItem inserts an item to the end of the list and set the current item index to the end of list. When given an index, it inserts the item to the specified index and sets the current item index to the given index.
final newSelectedItems = selectedItems.insertItem(10);
print(newSelectedItems.items); // [1, 2, 3, 4, 5, 10]
print(newSelectedItems.currentItem); // 10
Deletes the item at the specified index.
final newSelectedItems = selectedItems.deleteItem(2);
print(newselectedItems.items); // [1, 2, 4, 5];
print(newSelectedItems.currentItem); // 2
final newSelectedItems = selectedItems.modifyItem(0, 10);
print(newselectedItems.items); // [10, 2, 3, 4, 5];
print(newSelectedItems.currentItem); // 10
N/A