Interface for selectable options in dropdowns, radio buttons, etc.
Implement this on your enum or class to make it usable in option-based form inputs. The title provides the display text for the UI.
Example with enum:
enum Priority with Option<UIText> {
low, medium, high;
@override
UIText get title => switch (this) {
Priority.low => SimpleText('Low'),
Priority.medium => SimpleText('Medium'),
Priority.high => SimpleText('High'),
};
}
Example with class:
class Country with Option<UIText> {
final String code;
final String name;
@override
UIText get title => SimpleText(name);
}
Constructors
- Option()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title → T
-
The display text for this option in the UI.
no setter
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.
inherited