Checkbox
A checkbox records an independent yes-or-no choice. A short action label makes it clear what checking the box will include.
Request a receipt
#Check Email receipt, then clear it. The summary changes to show whether a receipt was requested.
components/checkbox/appliance/request_receipt.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class RequestReceipt extends StatefulWidget {
const RequestReceipt({super.key});
@override
State<RequestReceipt> createState() => _RequestReceiptState();
}
class _RequestReceiptState extends State<RequestReceipt> {
bool receipt = false;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 360),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceCheckbox(
semanticLabel: 'Email receipt',
value: receipt,
onChanged: (next) => setState(() => receipt = next ?? false),
),
const SizedBox(height: 12),
Text(
receipt ? 'Email receipt requested' : 'No email receipt requested',
),
],
),
);
}
Parameters
ApplianceCheckbox API ↗semanticLabel- Names the choice.
value- Whether a receipt is requested.
onChanged- Updates the request when the checkbox changes.
Shared behaviour
- Keyboard and focus. Tab to the checkbox and press Space to change its state. Press Space again to clear it.
- Screen readers. Read the label and checked state at the control. The sentence below describes the result of that choice.
- Direction and type. The label and result use the preview’s reading direction. Try larger text to inspect how they fit beside or below the checkbox.