Skip to content

Commit 90c524d

Browse files
authored
Update chip docs to clarify how to specify a shape with no border & explain default values for Material 3 (#134298)
fixes [Update chip docs for Material 3 defaults.](flutter/flutter#134296) Addresses a [comment](flutter/flutter#133856 (comment)) from @HansMuller as well
1 parent f851e7f commit 90c524d

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

packages/flutter/lib/src/material/chip.dart

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ abstract interface class ChipAttributes {
7676

7777
/// The style to be applied to the chip's label.
7878
///
79-
/// The default label style is [TextTheme.bodyLarge] from the overall
80-
/// theme's [ThemeData.textTheme].
79+
/// If this is null and [ThemeData.useMaterial3] is true, then
80+
/// [TextTheme.labelLarge] is used. Otherwise, [TextTheme.bodyLarge]
81+
/// is used.
8182
//
8283
/// This only has an effect on widgets that respect the [DefaultTextStyle],
8384
/// such as [Text].
@@ -95,12 +96,17 @@ abstract interface class ChipAttributes {
9596
/// The color and weight of the chip's outline.
9697
///
9798
/// Defaults to the border side in the ambient [ChipThemeData]. If the theme
98-
/// border side resolves to null, the default is the border side of [shape].
99+
/// border side resolves to null and [ThemeData.useMaterial3] is true, then
100+
/// [BorderSide] with a [ColorScheme.outline] color is used when the chip is
101+
/// enabled, and [BorderSide] with a [ColorScheme.onSurface] color with an
102+
/// opacity of 0.12 is used when the chip is disabled. Otherwise, it defaults
103+
/// to null.
99104
///
100105
/// This value is combined with [shape] to create a shape decorated with an
101-
/// outline. If it is a [MaterialStateBorderSide],
102-
/// [MaterialStateProperty.resolve] is used for the following
103-
/// [MaterialState]s:
106+
/// outline. To omit the outline entirely, pass [BorderSide.none] to [side].
107+
///
108+
/// If it is a [MaterialStateBorderSide], [MaterialStateProperty.resolve] is
109+
/// used for the following [MaterialState]s:
104110
///
105111
/// * [MaterialState.disabled].
106112
/// * [MaterialState.selected].
@@ -112,12 +118,15 @@ abstract interface class ChipAttributes {
112118
/// The [OutlinedBorder] to draw around the chip.
113119
///
114120
/// Defaults to the shape in the ambient [ChipThemeData]. If the theme
115-
/// shape resolves to null, the default is [StadiumBorder].
121+
/// shape resolves to null and [ThemeData.useMaterial3] is true, then
122+
/// [RoundedRectangleBorder] with a circular border radius of 8.0 is used.
123+
/// Otherwise, [StadiumBorder] is used.
116124
///
117125
/// This shape is combined with [side] to create a shape decorated with an
118-
/// outline. If it is a [MaterialStateOutlinedBorder],
119-
/// [MaterialStateProperty.resolve] is used for the following
120-
/// [MaterialState]s:
126+
/// outline. To omit the outline entirely, pass [BorderSide.none] to [side].
127+
///
128+
/// If it is a [MaterialStateOutlinedBorder], [MaterialStateProperty.resolve]
129+
/// is used for the following [MaterialState]s:
121130
///
122131
/// * [MaterialState.disabled].
123132
/// * [MaterialState.selected].
@@ -139,6 +148,8 @@ abstract interface class ChipAttributes {
139148

140149
/// The color that fills the chip, in all [MaterialState]s.
141150
///
151+
/// Defaults to null.
152+
///
142153
/// Resolves in the following states:
143154
/// * [MaterialState.selected].
144155
/// * [MaterialState.disabled].
@@ -151,7 +162,9 @@ abstract interface class ChipAttributes {
151162

152163
/// The padding between the contents of the chip and the outside [shape].
153164
///
154-
/// Defaults to 4 logical pixels on all sides.
165+
/// If this is null and [ThemeData.useMaterial3] is true, then
166+
/// a padding of 8.0 logical pixels on all sides is used. Otherwise,
167+
/// it defaults to a padding of 4.0 logical pixels on all sides.
155168
EdgeInsetsGeometry? get padding;
156169

157170
/// Defines how compact the chip's layout will be.
@@ -190,18 +203,25 @@ abstract interface class ChipAttributes {
190203

191204
/// Color of the chip's shadow when the elevation is greater than 0.
192205
///
193-
/// The default is null.
206+
/// If this is null and [ThemeData.useMaterial3] is true, then
207+
/// [Colors.transparent] color is used. Otherwise, it defaults to null.
194208
Color? get shadowColor;
195209

196210
/// Color of the chip's surface tint overlay when its elevation is
197211
/// greater than 0.
198212
///
199-
/// The default is null.
213+
/// If this is null and [ThemeData.useMaterial3] is true, then
214+
/// [ColorScheme.surfaceTint] color is used. Otherwise, it defaults
215+
/// to null.
200216
Color? get surfaceTintColor;
201217

202218
/// Theme used for all icons in the chip.
203219
///
204-
/// The default is null.
220+
/// If this is null and [ThemeData.useMaterial3] is true, then [IconThemeData]
221+
/// with a [ColorScheme.primary] color and a size of 18.0 is used when
222+
/// the chip is enabled, and [IconThemeData] with a [ColorScheme.onSurface]
223+
/// color and a size of 18.0 is used when the chip is disabled. Otherwise,
224+
/// it defaults to null.
205225
IconThemeData? get iconTheme;
206226
}
207227

0 commit comments

Comments
 (0)