ExpressiveChip class
A Material 3 chip, one of Compose's four:
- ExpressiveChip.assist: a smart action from the content (
AssistChip,ElevatedAssistChip), its icon inprimary. - ExpressiveChip.filter: a toggle among options (
FilterChip,ElevatedFilterChip); selected, it fills withsecondaryContainerand its leading slot shows the check (the pattern Compose's samples and Material's guidance give), springing open. - ExpressiveChip.input: a piece of entered information
(
InputChip), with an avatar or icon and a remove control. - ExpressiveChip.suggestion: a dynamically suggested reply or query
(
SuggestionChip,ElevatedSuggestionChip).
ExpressiveChip.new picks one the way Material's chips are told apart: with onDeleted an input chip, with selected a filter chip, else an assist chip. A press is onPressed on every kind; a filter chip's handler flips the selection it is given.
32dp tall on its token shape, inside Compose's 48dp touch target.
ExpressiveChip('Vegetarian', selected: veg, onPressed: () => setState(() => veg = !veg))
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ExpressiveChip
Constructors
- ExpressiveChip(String label, {VoidCallback? onPressed, ExpressiveComponentThemeData? style, bool? selected, VoidCallback? onDeleted, String? deleteLabel, IconData? icon, bool enabled = true, Key? key, FocusNode? focusNode, bool autofocus = false})
-
A chip labelled
label: an input chip withonDeleted, a filter chip withselected, else an assist chip.const - ExpressiveChip.assist(String label, {VoidCallback? onPressed, ExpressiveComponentThemeData? style, IconData? icon, IconData? trailingIcon, bool elevated = false, bool enabled = true, Key? key, FocusNode? focusNode, bool autofocus = false})
-
An assist chip.
const
- ExpressiveChip.filter(String label, {required bool selected, VoidCallback? onPressed, ExpressiveComponentThemeData? style, IconData? icon, IconData? trailingIcon, bool elevated = false, bool morph = false, bool enabled = true, Key? key, FocusNode? focusNode, bool autofocus = false})
-
A filter chip:
onPressedflipsselected.const - ExpressiveChip.input(String label, {bool selected = false, VoidCallback? onPressed, ExpressiveComponentThemeData? style, VoidCallback? onDeleted, String? deleteLabel, Widget? avatar, IconData? icon, bool morph = false, bool enabled = true, Key? key, FocusNode? focusNode, bool autofocus = false})
-
An input chip.
const
- ExpressiveChip.suggestion(String label, {VoidCallback? onPressed, ExpressiveComponentThemeData? style, IconData? icon, bool elevated = false, bool enabled = true, Key? key, FocusNode? focusNode, bool autofocus = false})
-
A suggestion chip.
const
Properties
- autofocus → bool
-
Whether it takes focus when first built.
final
- avatar → Widget?
-
An input chip's avatar, clipped to a 24dp circle; wins over icon.
final
- deleteLabel → String?
-
What a screen reader calls the remove target (Material's
deleteButtonTooltipMessage); "Remove label" when null.final - elevated → bool
-
The elevated style (assist, filter, suggestion): a
surfaceContainerLowcontainer on a level 1 shadow, no outline.final - enabled → bool
-
Whether the chip takes input; disabled colours when false.
final
- focusNode → FocusNode?
-
The focus node of its press target; null lets the target keep its own.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → IconData?
-
The leading glyph (a filter chip shows the check in its place while
selected).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → String
-
The chip's text, one line.
final
- morph → bool
-
Whether a filter or input chip morphs its shape (Compose's
ChipShapes: medium at rest, full selected, small pressed).final - onDeleted → VoidCallback?
-
Removes an input chip: shows the trailing close glyph as its own
target.
final
- onPressed → VoidCallback?
-
What a tap does; a filter chip's flips its selection. The chip is out
of use when null.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selected → bool
-
Whether a filter or input chip is selected.
final
- style → ExpressiveComponentThemeData?
-
Stateful visual overrides before the chip theme.
final
- trailingIcon → IconData?
-
The trailing glyph (assist and filter: a dropdown arrow, say).
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited