Choice<T> class
Represents a selectable choice item.
The key field serves dual purposes:
- Unique identification for validation and selection tracking
- Grouping: if key is null or empty, the choice acts as a group title
Example:
List<Choice<Car>> choices = [
Choice(null, 'Sports Cars'), // Group title
Choice('1', 'Ferrari', metadata: Car(...)),
Choice('2', 'Porsche', metadata: Car(...)),
Choice(null, 'SUVs'), // Another group title
Choice('3', 'Range Rover', metadata: Car(...)),
];
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isGroupingTitle → bool
-
Available on Choice<
A choice acts as a grouping title when it has no key.T> , provided by the ChoiceMenuExtension extensionno setter - key → String?
-
final
- metadata → T?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String
-
final
Methods
-
isFirstSelectedIn(
List< Choice< selectedChoice) → boolT> > -
Available on Choice<
Whether this choice occupies the first slot inT> , provided by the ChoiceMenuExtension extensionselectedChoice. -
isSelectedIn(
List< Choice< selectedChoice) → boolT> > -
Available on Choice<
Whether this choice is currently selected withinT> , provided by the ChoiceMenuExtension extensionselectedChoice. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override