Meter
A meter compares a current amount with a known limit. It can stay at the same value until the thing being measured changes.
Check room capacity
#The room holds eight people. Add two at a time and watch the level and count change. Reset the room when all eight places are taken.
components/meter/appliance/check_capacity.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class CheckCapacity extends StatefulWidget {
const CheckCapacity({super.key});
@override
State<CheckCapacity> createState() => _CheckCapacityState();
}
class _CheckCapacityState extends State<CheckCapacity> {
int people = 2;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 320),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceMeter(value: people / 8, label: 'Room capacity'),
const SizedBox(height: 12),
Text('Using $people of 8 places'),
const SizedBox(height: 12),
ApplianceButton(
people == 8 ? 'Reset room' : 'Add two people',
onPressed: () =>
setState(() => people = people == 8 ? 2 : people + 2),
),
],
),
);
}
Parameters
ApplianceMeter API ↗value- Occupied fraction between zero and one.
label- Names the measured quantity.
high- Sets the threshold for a high reading.
Shared behaviour
- Keyboard and focus. Tab to Add two people. Activate it to change the measured amount. The meter itself is a readout.
- Screen readers. Read the count after each change. The separate text gives the units and the capacity alongside the look’s own meter semantics.
- Direction and type. Try the compact readout with the page set to RTL and larger type.