Chip constructor
const
Chip({
- Key? key,
- required Widget child,
- Widget? leading,
- Widget? trailing,
- VoidCallback? onPressed,
- AbstractButtonStyle? style,
Creates a Chip.
The chip displays child content with optional leading and trailing
widgets. When onPressed is provided, the entire chip becomes interactive.
Parameters:
child(Widget, required): main content displayed in the chip centerleading(Widget?, optional): widget displayed before the main contenttrailing(Widget?, optional): widget displayed after the main contentonPressed(VoidCallback?, optional): callback when chip is pressedstyle(AbstractButtonStyle?, optional): override chip button styling
Example:
Chip(
leading: Avatar(user: currentUser),
child: Text(currentUser.name),
trailing: ChipButton(
onPressed: () => removeUser(currentUser),
child: Icon(Icons.close, size: 16),
),
style: ButtonStyle.primary(),
)
Implementation
const Chip({
super.key,
required this.child,
this.leading,
this.trailing,
this.onPressed,
this.style,
});