Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

wxxedu/selectable_items

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Features

N / A

This package is deprecated.

Getting started

This package depends on the freezed and freezed_annotation package.

Usage

Initialize

final selectedItems = SelectableItems(
    currentIndex: 0,
    items: [1, 2, 3, 4, 5],
)

Get the current item

print(selectableItems.currentItem); // 1

Selects an item

final newSelectedItems = selectedItems.selectItem(2);
print(newSelectedItems.currentItem); // 3

Inserts an item

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 an item

Deletes the item at the specified index.

final newSelectedItems = selectedItems.deleteItem(2);
print(newselectedItems.items); // [1, 2, 4, 5];
print(newSelectedItems.currentItem); // 2

Modifies an item

final newSelectedItems = selectedItems.modifyItem(0, 10);
print(newselectedItems.items); // [10, 2, 3, 4, 5];
print(newSelectedItems.currentItem); // 10

Additional information

N/A

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages