Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 91dc513

Browse files
authored
Add missing parameters to CheckboxListTile (#120118)
* Add missing parameters to CheckboxListTile * Update test message and api doc * Reorder parameters --------- Co-authored-by: Qun Cheng <[email protected]>
1 parent c8c8621 commit 91dc513

File tree

3 files changed

+541
-30
lines changed

3 files changed

+541
-30
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ class Checkbox extends StatefulWidget {
254254
/// [ThemeData.focusColor] is used.
255255
final Color? focusColor;
256256

257+
/// {@template flutter.material.checkbox.hoverColor}
257258
/// The color for the checkbox's [Material] when a pointer is hovering over it.
258259
///
259260
/// If [overlayColor] returns a non-null color in the [MaterialState.hovered]
260261
/// state, it will be used instead.
262+
/// {@endtemplate}
261263
///
262264
/// If null, then the value of [CheckboxThemeData.overlayColor] is used in the
263265
/// hovered state. If that is also null, then the value of
@@ -332,10 +334,12 @@ class Checkbox extends StatefulWidget {
332334
/// will be width 2.
333335
final BorderSide? side;
334336

337+
/// {@template flutter.material.checkbox.isError}
335338
/// True if this checkbox wants to show an error state.
336339
///
337340
/// The checkbox will have different default container color and check color when
338341
/// this is true. This is only used when [ThemeData.useMaterial3] is set to true.
342+
/// {@endtemplate}
339343
///
340344
/// Must not be null. Defaults to false.
341345
final bool isError;

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

Lines changed: 102 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,20 @@ class CheckboxListTile extends StatelessWidget {
163163
super.key,
164164
required this.value,
165165
required this.onChanged,
166+
this.mouseCursor,
166167
this.activeColor,
168+
this.fillColor,
167169
this.checkColor,
170+
this.hoverColor,
171+
this.overlayColor,
172+
this.splashRadius,
173+
this.materialTapTargetSize,
174+
this.visualDensity,
175+
this.focusNode,
176+
this.autofocus = false,
177+
this.shape,
178+
this.side,
179+
this.isError = false,
168180
this.enabled,
169181
this.tileColor,
170182
this.title,
@@ -174,15 +186,10 @@ class CheckboxListTile extends StatelessWidget {
174186
this.secondary,
175187
this.selected = false,
176188
this.controlAffinity = ListTileControlAffinity.platform,
177-
this.autofocus = false,
178189
this.contentPadding,
179190
this.tristate = false,
180-
this.shape,
181191
this.checkboxShape,
182192
this.selectedTileColor,
183-
this.side,
184-
this.visualDensity,
185-
this.focusNode,
186193
this.onFocusChange,
187194
this.enableFeedback,
188195
}) : assert(tristate || value != null),
@@ -219,16 +226,98 @@ class CheckboxListTile extends StatelessWidget {
219226
/// {@end-tool}
220227
final ValueChanged<bool?>? onChanged;
221228

229+
/// The cursor for a mouse pointer when it enters or is hovering over the
230+
/// widget.
231+
///
232+
/// If [mouseCursor] is a [MaterialStateProperty<MouseCursor>],
233+
/// [MaterialStateProperty.resolve] is used for the following [MaterialState]s:
234+
///
235+
/// * [MaterialState.selected].
236+
/// * [MaterialState.hovered].
237+
/// * [MaterialState.disabled].
238+
///
239+
/// If null, then the value of [CheckboxThemeData.mouseCursor] is used. If
240+
/// that is also null, then [MaterialStateMouseCursor.clickable] is used.
241+
final MouseCursor? mouseCursor;
242+
222243
/// The color to use when this checkbox is checked.
223244
///
224245
/// Defaults to [ColorScheme.secondary] of the current [Theme].
225246
final Color? activeColor;
226247

248+
/// The color that fills the checkbox.
249+
///
250+
/// Resolves in the following states:
251+
/// * [MaterialState.selected].
252+
/// * [MaterialState.hovered].
253+
/// * [MaterialState.disabled].
254+
///
255+
/// If null, then the value of [activeColor] is used in the selected
256+
/// state. If that is also null, the value of [CheckboxThemeData.fillColor]
257+
/// is used. If that is also null, then the default value is used.
258+
final MaterialStateProperty<Color?>? fillColor;
259+
227260
/// The color to use for the check icon when this checkbox is checked.
228261
///
229262
/// Defaults to Color(0xFFFFFFFF).
230263
final Color? checkColor;
231264

265+
/// {@macro flutter.material.checkbox.hoverColor}
266+
final Color? hoverColor;
267+
268+
/// The color for the checkbox's [Material].
269+
///
270+
/// Resolves in the following states:
271+
/// * [MaterialState.pressed].
272+
/// * [MaterialState.selected].
273+
/// * [MaterialState.hovered].
274+
///
275+
/// If null, then the value of [activeColor] with alpha [kRadialReactionAlpha]
276+
/// and [hoverColor] is used in the pressed and hovered state. If that is also null,
277+
/// the value of [CheckboxThemeData.overlayColor] is used. If that is also null,
278+
/// then the the default value is used in the pressed and hovered state.
279+
final MaterialStateProperty<Color?>? overlayColor;
280+
281+
/// {@macro flutter.material.checkbox.splashRadius}
282+
///
283+
/// If null, then the value of [CheckboxThemeData.splashRadius] is used. If
284+
/// that is also null, then [kRadialReactionRadius] is used.
285+
final double? splashRadius;
286+
287+
/// {@macro flutter.material.checkbox.materialTapTargetSize}
288+
///
289+
/// Defaults to [MaterialTapTargetSize.shrinkWrap].
290+
final MaterialTapTargetSize? materialTapTargetSize;
291+
292+
/// Defines how compact the list tile's layout will be.
293+
///
294+
/// {@macro flutter.material.themedata.visualDensity}
295+
final VisualDensity? visualDensity;
296+
297+
298+
/// {@macro flutter.widgets.Focus.focusNode}
299+
final FocusNode? focusNode;
300+
301+
/// {@macro flutter.widgets.Focus.autofocus}
302+
final bool autofocus;
303+
304+
/// {@macro flutter.material.ListTile.shape}
305+
final ShapeBorder? shape;
306+
307+
/// {@macro flutter.material.checkbox.side}
308+
///
309+
/// The given value is passed directly to [Checkbox.side].
310+
///
311+
/// If this property is null, then [CheckboxThemeData.side] of
312+
/// [ThemeData.checkboxTheme] is used. If that is also null, then the side
313+
/// will be width 2.
314+
final BorderSide? side;
315+
316+
/// {@macro flutter.material.checkbox.isError}
317+
///
318+
/// Defaults to false.
319+
final bool isError;
320+
232321
/// {@macro flutter.material.ListTile.tileColor}
233322
final Color? tileColor;
234323

@@ -270,9 +359,6 @@ class CheckboxListTile extends StatelessWidget {
270359
/// Where to place the control relative to the text.
271360
final ListTileControlAffinity controlAffinity;
272361

273-
/// {@macro flutter.widgets.Focus.autofocus}
274-
final bool autofocus;
275-
276362
/// Defines insets surrounding the tile's contents.
277363
///
278364
/// This value will surround the [Checkbox], [title], [subtitle], and [secondary]
@@ -293,9 +379,6 @@ class CheckboxListTile extends StatelessWidget {
293379
/// If tristate is false (the default), [value] must not be null.
294380
final bool tristate;
295381

296-
/// {@macro flutter.material.ListTile.shape}
297-
final ShapeBorder? shape;
298-
299382
/// {@macro flutter.material.checkbox.shape}
300383
///
301384
/// If this property is null then [CheckboxThemeData.shape] of [ThemeData.checkboxTheme]
@@ -306,23 +389,6 @@ class CheckboxListTile extends StatelessWidget {
306389
/// If non-null, defines the background color when [CheckboxListTile.selected] is true.
307390
final Color? selectedTileColor;
308391

309-
/// {@macro flutter.material.checkbox.side}
310-
///
311-
/// The given value is passed directly to [Checkbox.side].
312-
///
313-
/// If this property is null, then [CheckboxThemeData.side] of
314-
/// [ThemeData.checkboxTheme] is used. If that is also null, then the side
315-
/// will be width 2.
316-
final BorderSide? side;
317-
318-
/// Defines how compact the list tile's layout will be.
319-
///
320-
/// {@macro flutter.material.themedata.visualDensity}
321-
final VisualDensity? visualDensity;
322-
323-
/// {@macro flutter.widgets.Focus.focusNode}
324-
final FocusNode? focusNode;
325-
326392
/// {@macro flutter.material.inkwell.onFocusChange}
327393
final ValueChanged<bool>? onFocusChange;
328394

@@ -359,14 +425,20 @@ class CheckboxListTile extends StatelessWidget {
359425
Widget build(BuildContext context) {
360426
final Widget control = Checkbox(
361427
value: value,
362-
onChanged: enabled ?? true ? onChanged : null ,
428+
onChanged: enabled ?? true ? onChanged : null,
429+
mouseCursor: mouseCursor,
363430
activeColor: activeColor,
431+
fillColor: fillColor,
364432
checkColor: checkColor,
365-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
433+
hoverColor: hoverColor,
434+
overlayColor: overlayColor,
435+
splashRadius: splashRadius,
436+
materialTapTargetSize: materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
366437
autofocus: autofocus,
367438
tristate: tristate,
368439
shape: checkboxShape,
369440
side: side,
441+
isError: isError,
370442
);
371443
Widget? leading, trailing;
372444
switch (controlAffinity) {

0 commit comments

Comments
 (0)