Number field
A number field lets someone adjust a quantity in predictable steps. Set a meaningful lower bound, such as one copy of a document.
Choose a quantity
#Start with two copies. Add a copy, then lower the count to one and try to decrease it again.
components/number-field/appliance/count_copies.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class CountCopies extends StatefulWidget {
const CountCopies({super.key});
@override
State<CountCopies> createState() => _CountCopiesState();
}
class _CountCopiesState extends State<CountCopies> {
int copies = 2;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceStepper(
semanticLabel: 'Copies',
min: 1,
max: 9,
value: copies,
onChanged: (value) => setState(() => copies = value),
),
const SizedBox(height: 12),
Text('Copies: $copies'),
],
),
);
}
Parameters
ApplianceStepper API ↗semanticLabel- Identifies the quantity being adjusted.
min- Smallest quantity allowed.
max- Largest quantity allowed.
value- Current number of copies.
onChanged- Keeps the field and the total in sync.
Shared behaviour
- Keyboard and focus. Tab to the control. Depending on the look, use its increase and decrease actions or the Up and Down arrows on the value.
- Screen readers. Read the current quantity and the names of its adjustment controls. The total below the field also reports the number of copies.
- Direction and type. The adjustment controls follow the look’s reading order. Try the phone frame with larger type to inspect the number and its neighbours.