Card
A card keeps a small piece of content and its actions together. Give the group a subject that still makes sense when the card stands on its own.
Pin a note
#Pin the route note. Its action changes to Unpin so you can remove the pin again.
components/card/appliance/pin_note.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class PinNote extends StatefulWidget {
const PinNote({super.key});
@override
State<PinNote> createState() => _PinNoteState();
}
class _PinNoteState extends State<PinNote> {
bool pinned = false;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: SingleChildScrollView(
child: AppliancePanel(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Route note'),
const SizedBox(height: 12),
const Text('Meet at the west entrance.'),
const SizedBox(height: 12),
ApplianceButton(
pinned ? 'Unpin' : 'Pin',
onPressed: () => setState(() => pinned = !pinned),
),
],
),
),
),
);
}
Parameters
AppliancePanel API ↗child- What it holds.
padding- Sets the space between the frame and its content.
onTap- Runs when the reader activates the component. Leave it unset for a read-only item.
semanticLabel- What a screen reader calls a pressable plate.
clip- Whether child is clipped to the plate's corners.
style- Its style, over ApplianceThemeData.panelStyle.
Shared behaviour
- Keyboard and focus. Tab to the action inside the card and activate it with Enter or Space.
- Screen readers. Read the note, then the action. After pinning, its name changes to Unpin.
- Direction and type. The note and its action stay together when the leading edge changes in RTL. Try the narrow preview at 200% to see the note wrap.