Icon button
An icon button puts a familiar action in a toolbar or beside an item. Choose a symbol people recognise and give it a name that describes the action.
Add a day
#Activate the plus to extend a loan by one day. The number below it shows the new loan period.
components/icon-button/appliance/add_a_day.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
import 'package:flutter/cupertino.dart' show CupertinoIcons;
class AddADay extends StatefulWidget {
const AddADay({super.key});
@override
State<AddADay> createState() => _AddADayState();
}
class _AddADayState extends State<AddADay> {
int days = 7;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceIconButton(
icon: const Icon(CupertinoIcons.plus),
semanticLabel: 'Add a day',
onPressed: () => setState(() => days++),
),
const SizedBox(height: 12),
Text('Loan period: $days days'),
],
);
}
Parameters
ApplianceIconButton API ↗icon- Plus symbol for extending the loan.
semanticLabel- Accessible name for the icon-only action.
onPressed- Adds one day to the current loan period.
Shared behaviour
- Keyboard and focus. Tab to the plus and activate it with Enter or Space. You can press it again without leaving the control.
- Screen readers. The action is named “Add a day”. Read the text below it for the current loan period.
- Direction and type. The plus keeps its meaning in either direction. Its spoken name stays available even when the control shows just the icon.