Choice<T> class

Represents a selectable choice item.

The key field serves dual purposes:

  1. Unique identification for validation and selection tracking
  2. 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(...)),
];

Constructors

Choice(String? key, String value, {T? metadata})
const

Properties

hashCode int
The hash code for this object.
no setteroverride
key String?
final
metadata → T?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String
final

Methods

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