Select
Use a select for one answer from a fixed list. Name the field for the decision and each option for the value that will be kept.
Choose a paper size
#Open Paper size and choose A5 or Letter. The print summary reflects the committed choice.
components/select/appliance/choose_paper.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class ChoosePaper extends StatefulWidget {
const ChoosePaper({super.key});
@override
State<ChoosePaper> createState() => _ChoosePaperState();
}
class _ChoosePaperState extends State<ChoosePaper> {
String paper = 'A4';
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceSelect<String>(
label: 'Paper size',
value: paper,
items: const [
ApplianceSelectItem(value: 'A4', label: 'A4'),
ApplianceSelectItem(value: 'A5', label: 'A5'),
ApplianceSelectItem(value: 'Letter', label: 'Letter'),
],
onChanged: (value) => setState(() => paper = value),
),
const SizedBox(height: 12),
Text('Print on $paper'),
],
),
);
}
Parameters
ApplianceSelect API ↗label- Visible name of the selection field.
items- Paper sizes in menu order.
value- Currently committed paper size.
onChanged- Runs when the reader chooses a paper size.
Shared behaviour
- Keyboard and focus. Tab to the select and open its list. Use the arrows and Enter to choose, or Escape to leave the previous value in place.
- Screen readers. Listen for the field name and current value. In the list, each paper size has a distinct name.
- Direction and type. The menu inherits the preview direction and text scale. Try opening it in the narrow frame at 200%.