CivicSelect<T> class

One answer from a list too long for radios: the field's box with the answer in it and a chevron, opening the list under it, floating on a hairline and a soft shadow. The chosen row stands on the inset rule in the action colour, bold and ticked; a pointer greys a row; the focused row stands on the yellow plate. From 600 wide it keeps to 320 points: a select is as wide as its answers.

The keys, as a platform's own select: Enter, Space or Down open the list with the focus on the answer chosen (the first answer while none is), and so does a press, so the arrows go on from there. Up and Down walk the list, round from one end to the other; Home and End go to its ends; a letter typed goes to the next answer starting with it (letters typed quickly spell an answer's start). Enter or Space takes the answer and closes the list, Escape closes it; either way the focus is back on the field.

Prefer CivicRadioGroup for seven answers or fewer: radios show every answer at once.

Reads CivicStyle's fill, foreground and edge, by state: its style:, then CivicThemeData.selectStyle. The list, the edge's width and the focus ring are the look's.

CivicSelect<String>(
  labelText: 'Permit zone',
  value: zone,
  onChanged: (value) => setState(() => zone = value),
  items: const [
    CivicSelectItem(value: 'a', label: 'Zone A: Old Town'),
    CivicSelectItem(value: 'b', label: 'Zone B: Harbourside'),
  ],
)
Inheritance

Constructors

CivicSelect({Key? key, required T? value, required ValueChanged<T>? onChanged, required List<CivicSelectItem<T>> items, String? labelText, String? helperText, String? errorText, String? hintText, FocusNode? focusNode, bool autofocus = false, CivicStyle? style})
A select.
const

Properties

autofocus → bool
Whether it takes the focus when it first appears.
final
errorText → String?
What to fix; null while the answer is fine.
final
focusNode → FocusNode?
The focus node, which the caller disposes; null makes one of its own.
final
hashCode → int
The hash code for this object.
no setterinherited
helperText → String?
How to answer.
final
hintText → String?
Shown while nothing is chosen.
final
items → List<CivicSelectItem<T>>
The answers.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
labelText → String?
What the select asks.
final
onChanged → ValueChanged<T>?
Called with an answer as it is chosen; null disables the select.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
style → CivicStyle?
Overrides for this select's look.
final
value → T?
The answer chosen; null while none is.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<CivicSelect<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

maxWidth → const double
The widest a select stands from 600.