ExpandableList
A read-only, immutable list wrapper that supports expandable and collapsible behavior.
This class behaves like a standard List but adds metadata and logic to control visibility of its elements based on a specified minimumVisibleItems threshold and current isCollapsed state.
Behavior:
When isCollapsed is
true
and the total item count exceeds minimumVisibleItems, only the first minimumVisibleItems items are exposed through the list interface. The remaining items are considered collapsed.When isCollapsed is
false
, all items are exposed.If the total number of items is less than or equal to minimumVisibleItems, all items are shown, and the list is not expandable.
Parameters
the type of elements contained in the list.
the full list of items to wrap.
the minimum number of items to show when collapsed. Defaults to the full list size (no collapsing by default).
whether the list is currently collapsed (hiding excess items).
Properties
Indicates whether the list can be expanded or collapsed, i.e., when the number of items exceeds minimumVisibleItems.
The number of items that are currently collapsed (not visible). Returns 0
if the list is expanded or cannot be expanded.