build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the UI represented by this widget.

Implementation

@override
Widget build(BuildContext context) {
  final theme = ThemeScope.of(context);
  final delete = deleteIcon ?? Text('x', style: theme.labelSmall);

  final children = <Widget>[
    if (avatar != null) avatar!,
    _resolveLabel(theme),
    if (onDeleted != null) GestureDetector(onTap: onDeleted, child: delete),
  ];

  Widget chip = Frame(
    border: Border.rounded,
    borderColor: theme.border,
    background: backgroundColor ?? theme.surface,
    padding:
        padding ?? const EdgeInsets.symmetric(horizontal: 1, vertical: 0),
    child: Row(gap: 1, children: children),
  );

  if (!enabled) {
    chip = Opacity(opacity: 0.7, child: chip);
  }

  return chip;
}