build method
Build the widget.
Implementation
@override
Widget build(final BuildContext context) => Semantics(
customSemanticsActions: {
for (final v in values.where((final e) => e != value))
CustomSemanticsAction(label: _getValueName(v)): () => onChanged(v),
if (nullable)
CustomSemanticsAction(label: emptyValue): () => onChanged(null),
},
child: MenuAnchor(
menuChildren: [
if (nullable)
Semantics(
checked: value == null,
selected: true,
child: MenuItemButton(
autofocus: value == null,
child: Text(emptyValue),
onPressed: () => onChanged(null),
),
),
...values.map(
(final v) {
final checked = v == value;
return Semantics(
checked: checked,
selected: true,
child: MenuItemButton(
autofocus: checked,
onPressed: () => onChanged(v),
trailingIcon: SelectedIcon(selected: checked),
child: Text(_getValueName(v)),
),
);
},
),
],
builder: (final context, final controller, final child) => ListTile(
autofocus: autofocus,
title: Text(title),
subtitle: Text(_getValueName(value)),
onTap: controller.toggle,
onLongPress: onLongPress,
),
),
);