Chip constructor

const Chip({
  1. Key? key,
  2. required Widget child,
  3. Widget? leading,
  4. Widget? trailing,
  5. VoidCallback? onPressed,
  6. 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 center
  • leading (Widget?, optional): widget displayed before the main content
  • trailing (Widget?, optional): widget displayed after the main content
  • onPressed (VoidCallback?, optional): callback when chip is pressed
  • style (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,
});