Skip to main content

InputChipAppi

A customizable input chip widget for displaying selectable and deletable tags or options in Flutter applications.

Features

  • Interactive Chips: Tap to select/deselect with visual feedback
  • Deletable: Optional delete functionality with customizable delete icon
  • Custom Styling: Configurable colors, shapes, and visual properties
  • Avatar Support: Optional leading avatar or icon
  • Flexible Content: Support for text labels and custom styling
  • Material Design: Follows Material Design chip guidelines

Usage

InputChipAppi(
label: 'Flutter',
selected: true,
onSelected: (bool selected) {
setState(() {
isSelected = selected;
});
},
onDeleted: () {
// Remove chip logic
},
)

Parameters

ParameterTypeDescription
labelWidgetRequired. The primary content of the chip (usually Text)
avatarWidget?Optional leading widget (usually CircleAvatar or Icon)
selectedboolWhether the chip is selected (default: false)
onSelectedValueChanged<bool>?Callback when chip selection changes
onDeletedVoidCallback?Callback when delete button is pressed
deleteIconWidget?Custom delete icon (default: Icons.cancel)
deleteIconColorColor?Color of the delete icon
deleteButtonTooltipMessageString?Tooltip message for delete button
onPressedVoidCallback?Callback when chip is pressed
pressElevationdouble?Elevation when chip is pressed
disabledColorColor?Color when chip is disabled
selectedColorColor?Color when chip is selected
tooltipString?Tooltip message for the chip
shapeShapeBorder?Custom shape for the chip
clipBehaviorClipClip behavior for the chip (default: Clip.none)
focusNodeFocusNode?Focus node for keyboard navigation
autofocusboolWhether to autofocus (default: false)
backgroundColorColor?Background color of the chip
paddingEdgeInsets?Internal padding of the chip
visualDensityVisualDensity?Visual density for spacing
materialTapTargetSizeMaterialTapTargetSize?Size of the tap target
elevationdouble?Elevation of the chip
shadowColorColor?Shadow color of the chip
selectedShadowColorColor?Shadow color when selected
showCheckmarkbool?Whether to show checkmark when selected
checkmarkColorColor?Color of the checkmark
labelStyleTextStyle?Text style for the label
labelPaddingEdgeInsets?Padding around the label
sideBorderSide?Border side of the chip

Examples

Basic Input Chip

bool isSelected = false;

InputChipAppi(
label: Text('Technology'),
selected: isSelected,
onSelected: (bool selected) {
setState(() {
isSelected = selected;
});
},
)

Deletable Chip

List<String> tags = ['Flutter', 'Dart', 'Mobile'];

Wrap(
spacing: 8,
children: tags.map((tag) =>
InputChipAppi(
label: Text(tag),
onDeleted: () {
setState(() {
tags.remove(tag);
});
},
deleteIcon: Icon(Icons.close, size: 18),
),
).toList(),
)

Chip with Avatar

InputChipAppi(
avatar: CircleAvatar(
backgroundColor: Colors.blue,
child: Text('F', style: TextStyle(color: Colors.white)),
),
label: Text('Flutter Developer'),
selected: true,
selectedColor: Colors.blue[100],
onSelected: (bool selected) {
// Handle selection
},
)

Custom Styled Chip

InputChipAppi(
label: Text(
'Premium Feature',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
backgroundColor: Colors.purple,
selectedColor: Colors.purple[700],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
elevation: 4,
pressElevation: 8,
onSelected: (bool selected) {
// Handle selection
},
)

Chip with Custom Delete Icon

InputChipAppi(
label: Text('Removable Tag'),
avatar: Icon(Icons.tag, size: 20),
deleteIcon: Icon(
Icons.remove_circle,
color: Colors.red,
size: 20,
),
deleteButtonTooltipMessage: 'Remove this tag',
onDeleted: () {
// Handle deletion
},
side: BorderSide(color: Colors.grey),
)

Interactive Chip List

class ChipData {
final String label;
final IconData icon;
bool isSelected;

ChipData(this.label, this.icon, {this.isSelected = false});
}

List<ChipData> chipList = [
ChipData('Work', Icons.work),
ChipData('Personal', Icons.person),
ChipData('Important', Icons.star),
ChipData('Travel', Icons.flight),
];

Wrap(
spacing: 8,
runSpacing: 8,
children: chipList.map((chipData) =>
InputChipAppi(
avatar: Icon(chipData.icon, size: 18),
label: Text(chipData.label),
selected: chipData.isSelected,
onSelected: (bool selected) {
setState(() {
chipData.isSelected = selected;
});
},
selectedColor: Colors.blue[100],
checkmarkColor: Colors.blue,
),
).toList(),
)

Disabled Chip

InputChipAppi(
label: Text('Disabled Chip'),
onSelected: null, // Disabled
disabledColor: Colors.grey[300],
avatar: Icon(Icons.block, color: Colors.grey),
)

Best Practices

  • Use Wrap widget to automatically handle chip overflow to new lines
  • Provide clear visual feedback for selected vs unselected states
  • Use appropriate spacing between chips for better touch targets
  • Consider using icons or avatars to make chips more recognizable
  • Implement proper state management for chip selection
  • Use consistent styling across all chips in your app
  • Provide tooltips for better accessibility
  • Consider the context when deciding between selectable and deletable chips