chip_theme.dart 24.1 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:ui' show lerpDouble;

7 8 9 10 11
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

import 'colors.dart';
12
import 'material_state.dart';
13 14 15 16 17 18
import 'theme.dart';

/// Applies a chip theme to descendant [RawChip]-based widgets, like [Chip],
/// [InputChip], [ChoiceChip], [FilterChip], and [ActionChip].
///
/// A chip theme describes the color, shape and text styles for the chips it is
19
/// applied to.
20 21 22 23 24 25
///
/// Descendant widgets obtain the current theme's [ChipThemeData] object using
/// [ChipTheme.of]. When a widget uses [ChipTheme.of], it is automatically
/// rebuilt if the theme later changes.
///
/// The [ThemeData] object given by the [Theme.of] call also contains a default
Dan Field's avatar
Dan Field committed
26
/// [ThemeData.chipTheme] that can be customized by copying it (using
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/// [ChipThemeData.copyWith]).
///
/// See also:
///
///  * [Chip], a chip that displays information and can be deleted.
///  * [InputChip], a chip that represents a complex piece of information, such
///    as an entity (person, place, or thing) or conversational text, in a
///    compact form.
///  * [ChoiceChip], allows a single selection from a set of options. Choice
///    chips contain related descriptive text or categories.
///  * [FilterChip], uses tags or descriptive words as a way to filter content.
///  * [ActionChip], represents an action related to primary content.
///  * [ChipThemeData], which describes the actual configuration of a chip
///    theme.
///  * [ThemeData], which describes the overall theme information for the
///    application.
43
class ChipTheme extends InheritedTheme {
44 45 46 47
  /// Applies the given theme [data] to [child].
  ///
  /// The [data] and [child] arguments must not be null.
  const ChipTheme({
48
    super.key,
49
    required this.data,
50
    required super.child,
51
  });
52 53 54 55 56 57 58 59 60 61 62

  /// Specifies the color, shape, and text style values for descendant chip
  /// widgets.
  final ChipThemeData data;

  /// Returns the data from the closest [ChipTheme] instance that encloses
  /// the given context.
  ///
  /// Defaults to the ambient [ThemeData.chipTheme] if there is no
  /// [ChipTheme] in the given build context.
  ///
63
  /// {@tool snippet}
64 65 66
  ///
  /// ```dart
  /// class Spaceship extends StatelessWidget {
67
  ///   const Spaceship({super.key});
68
  ///
69 70
  ///   @override
  ///   Widget build(BuildContext context) {
71
  ///     return ChipTheme(
72
  ///       data: ChipTheme.of(context).copyWith(backgroundColor: Colors.red),
73
  ///       child: ActionChip(
74 75 76 77 78 79 80
  ///         label: const Text('Launch'),
  ///         onPressed: () { print('We have liftoff!'); },
  ///       ),
  ///     );
  ///   }
  /// }
  /// ```
81
  /// {@end-tool}
82 83 84 85 86 87
  ///
  /// See also:
  ///
  ///  * [ChipThemeData], which describes the actual configuration of a chip
  ///    theme.
  static ChipThemeData of(BuildContext context) {
88
    final ChipTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<ChipTheme>();
89
    return inheritedTheme?.data ?? Theme.of(context).chipTheme;
90 91
  }

92 93
  @override
  Widget wrap(BuildContext context, Widget child) {
94
    return ChipTheme(data: data, child: child);
95 96
  }

97 98 99 100
  @override
  bool updateShouldNotify(ChipTheme oldWidget) => data != oldWidget.data;
}

101
/// Holds the color, shape, and text styles for a Material Design chip theme.
102 103 104 105 106 107 108 109 110 111 112 113 114 115
///
/// Use this class to configure a [ChipTheme] widget, or to set the
/// [ThemeData.chipTheme] for a [Theme] widget.
///
/// To obtain the current ambient chip theme, use [ChipTheme.of].
///
/// The parts of a chip are:
///
///  * The "avatar", which is a widget that appears at the beginning of the
///    chip. This is typically a [CircleAvatar] widget.
///  * The "label", which is the widget displayed in the center of the chip.
///    Typically this is a [Text] widget.
///  * The "delete icon", which is a widget that appears at the end of the chip.
///  * The chip is disabled when it is not accepting user input. Only some chips
116 117
///    have a disabled state: [ActionChip], [ChoiceChip], [FilterChip], and
///    [InputChip].
118 119 120
///
/// The simplest way to create a ChipThemeData is to use [copyWith] on the one
/// you get from [ChipTheme.of], or create an entirely new one with
121
/// [ChipThemeData.fromDefaults].
122
///
123
/// {@tool snippet}
124 125 126
///
/// ```dart
/// class CarColor extends StatefulWidget {
127
///   const CarColor({super.key});
128
///
129
///   @override
130
///   State createState() => _CarColorState();
131 132 133 134 135 136 137
/// }
///
/// class _CarColorState extends State<CarColor> {
///   Color _color = Colors.red;
///
///   @override
///   Widget build(BuildContext context) {
138
///     return ChipTheme(
139
///       data: ChipTheme.of(context).copyWith(backgroundColor: Colors.lightBlue),
140
///       child: ChoiceChip(
141
///         label: const Text('Light Blue'),
142 143 144 145 146 147 148 149 150 151 152
///         onSelected: (bool value) {
///           setState(() {
///             _color = value ? Colors.lightBlue : Colors.red;
///           });
///         },
///         selected: _color == Colors.lightBlue,
///       ),
///     );
///   }
/// }
/// ```
153
/// {@end-tool}
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
///
/// See also:
///
///  * [Chip], a chip that displays information and can be deleted.
///  * [InputChip], a chip that represents a complex piece of information, such
///    as an entity (person, place, or thing) or conversational text, in a
///    compact form.
///  * [ChoiceChip], allows a single selection from a set of options. Choice
///    chips contain related descriptive text or categories.
///  * [FilterChip], uses tags or descriptive words as a way to filter content.
///  * [ActionChip], represents an action related to primary content.
///  * [CircleAvatar], which shows images or initials of entities.
///  * [Wrap], A widget that displays its children in multiple horizontal or
///    vertical runs.
///  * [ChipTheme] widget, which can override the chip theme of its
///    children.
///  * [Theme] widget, which performs a similar function to [ChipTheme],
///    but for overall themes.
///  * [ThemeData], which has a default [ChipThemeData].
173
@immutable
174
class ChipThemeData with Diagnosticable {
175
  /// Create a [ChipThemeData] given a set of exact values. All the values
176 177
  /// must be specified except for [shadowColor], [selectedShadowColor],
  /// [elevation], and [pressElevation], which may be null.
178 179 180 181
  ///
  /// This will rarely be used directly. It is used by [lerp] to
  /// create intermediate themes based on two themes.
  const ChipThemeData({
182
    this.color,
183
    this.backgroundColor,
184
    this.deleteIconColor,
185 186 187
    this.disabledColor,
    this.selectedColor,
    this.secondarySelectedColor,
188
    this.shadowColor,
189
    this.surfaceTintColor,
190
    this.selectedShadowColor,
191 192
    this.showCheckmark,
    this.checkmarkColor,
193
    this.labelPadding,
194
    this.padding,
195 196
    this.side,
    this.shape,
197 198 199
    this.labelStyle,
    this.secondaryLabelStyle,
    this.brightness,
200 201
    this.elevation,
    this.pressElevation,
202
    this.iconTheme,
203
  });
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222

  /// Generates a ChipThemeData from a brightness, a primary color, and a text
  /// style.
  ///
  /// The [brightness] is used to select a primary color from the default
  /// values.
  ///
  /// The optional [primaryColor] is used as the base color for the other
  /// colors. The opacity of the [primaryColor] is ignored. If a [primaryColor]
  /// is specified, then the [brightness] is ignored, and the theme brightness
  /// is determined from the [primaryColor].
  ///
  /// Only one of [primaryColor] or [brightness] may be specified.
  ///
  /// The [secondaryColor] is used for the selection colors needed by
  /// [ChoiceChip].
  ///
  /// This is used to generate the default chip theme for a [ThemeData].
  factory ChipThemeData.fromDefaults({
223 224 225 226
    Brightness? brightness,
    Color? primaryColor,
    required Color secondaryColor,
    required TextStyle labelStyle,
227
  }) {
228 229
    assert(primaryColor != null || brightness != null, 'One of primaryColor or brightness must be specified');
    assert(primaryColor == null || brightness == null, 'Only one of primaryColor or brightness may be specified');
230 231 232 233 234 235 236 237 238 239 240 241

    if (primaryColor != null) {
      brightness = ThemeData.estimateBrightnessForColor(primaryColor);
    }

    // These are Material Design defaults, and are used to derive
    // component Colors (with opacity) from base colors.
    const int backgroundAlpha = 0x1f; // 12%
    const int deleteIconAlpha = 0xde; // 87%
    const int disabledAlpha = 0x0c; // 38% * 12% = 5%
    const int selectAlpha = 0x3d; // 12% + 12% = 24%
    const int textLabelAlpha = 0xde; // 87%
242
    const EdgeInsetsGeometry padding = EdgeInsets.all(4.0);
243 244 245 246 247 248 249 250 251 252 253 254

    primaryColor = primaryColor ?? (brightness == Brightness.light ? Colors.black : Colors.white);
    final Color backgroundColor = primaryColor.withAlpha(backgroundAlpha);
    final Color deleteIconColor = primaryColor.withAlpha(deleteIconAlpha);
    final Color disabledColor = primaryColor.withAlpha(disabledAlpha);
    final Color selectedColor = primaryColor.withAlpha(selectAlpha);
    final Color secondarySelectedColor = secondaryColor.withAlpha(selectAlpha);
    final TextStyle secondaryLabelStyle = labelStyle.copyWith(
      color: secondaryColor.withAlpha(textLabelAlpha),
    );
    labelStyle = labelStyle.copyWith(color: primaryColor.withAlpha(textLabelAlpha));

255
    return ChipThemeData(
256 257 258 259 260
      backgroundColor: backgroundColor,
      deleteIconColor: deleteIconColor,
      disabledColor: disabledColor,
      selectedColor: selectedColor,
      secondarySelectedColor: secondarySelectedColor,
261 262 263
      shadowColor: Colors.black,
      selectedShadowColor: Colors.black,
      showCheckmark: true,
264 265 266
      padding: padding,
      labelStyle: labelStyle,
      secondaryLabelStyle: secondaryLabelStyle,
267
      brightness: brightness,
268 269
      elevation: 0.0,
      pressElevation: 8.0,
270 271 272
    );
  }

273 274 275 276 277 278
  /// Overrides the default for [ChipAttributes.color].
  ///
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
  final MaterialStateProperty<Color?>? color;

279 280
  /// Overrides the default for [ChipAttributes.backgroundColor]
  /// which is used for unselected, enabled chip backgrounds.
281
  ///
282 283 284
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
  final Color? backgroundColor;
285

286
  /// Overrides the default for [DeletableChipAttributes.deleteIconColor].
287
  ///
288
  /// This property applies to [Chip], [InputChip], [RawChip].
289
  final Color? deleteIconColor;
290

291 292 293
  /// Overrides the default for
  /// [DisabledChipAttributes.disabledColor], the background color
  /// which indicates that the chip is not enabled.
294
  ///
295 296
  /// This property applies to [ActionChip], [ChoiceChip],
  /// [FilterChip], [InputChip], and [RawChip].
297
  final Color? disabledColor;
298

299 300 301
  /// Overrides the default for
  /// [SelectableChipAttributes.selectedColor], the background color
  /// that indicates that the chip is selected.
302
  ///
303 304 305
  /// This property applies to [ChoiceChip], [FilterChip],
  /// [InputChip], [RawChip].
  final Color? selectedColor;
306

307 308 309
  /// Overrides the default for [ChoiceChip.selectedColor], the
  /// background color that indicates that the chip is selected.
  final Color? secondarySelectedColor;
310

311 312
  /// Overrides the default for [ChipAttributes.shadowColor], the
  /// Color of the chip's shadow when its elevation is greater than 0.
313
  ///
314 315
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
316
  final Color? shadowColor;
317

318 319 320 321 322 323 324 325
  /// Overrides the default for [ChipAttributes.surfaceTintColor], the
  /// Color of the chip's surface tint overlay when its elevation is
  /// greater than 0.
  ///
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
  final Color? surfaceTintColor;

326 327 328 329
  /// Overrides the default for
  /// [SelectableChipAttributes.selectedShadowColor], the Color of the
  /// chip's shadow when its elevation is greater than 0 and the chip
  /// is selected.
330
  ///
331 332
  /// This property applies to [ChoiceChip], [FilterChip],
  /// [InputChip], [RawChip].
333
  final Color? selectedShadowColor;
334

335 336 337
  /// Overrides the default for
  /// [CheckmarkableChipAttributes.showCheckmark], which indicates if
  /// a check mark should be shown.
338
  ///
339
  /// This property applies to [FilterChip], [InputChip], [RawChip].
340
  final bool? showCheckmark;
341

342 343
  /// Overrides the default for
  /// [CheckmarkableChipAttributes.checkmarkColor].
344
  ///
345
  /// This property applies to [FilterChip], [InputChip], [RawChip].
346
  final Color? checkmarkColor;
347

348 349
  /// Overrides the default for [ChipAttributes.labelPadding],
  /// the padding around the chip's label widget.
350
  ///
351 352
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
353
  final EdgeInsetsGeometry? labelPadding;
354

355 356
  /// Overrides the default for [ChipAttributes.padding],
  /// the padding between the contents of the chip and the outside [shape].
357
  ///
358 359 360
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
  final EdgeInsetsGeometry? padding;
361

362 363
  /// Overrides the default for [ChipAttributes.side],
  /// the color and weight of the chip's outline.
364 365 366 367 368 369 370 371 372 373 374
  ///
  /// This value is combined with [shape] to create a shape decorated with an
  /// outline. If it is a [MaterialStateBorderSide],
  /// [MaterialStateProperty.resolve] is used for the following
  /// [MaterialState]s:
  ///
  ///  * [MaterialState.disabled].
  ///  * [MaterialState.selected].
  ///  * [MaterialState.hovered].
  ///  * [MaterialState.focused].
  ///  * [MaterialState.pressed].
375 376 377
  ///
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
378 379
  final BorderSide? side;

380 381
  /// Overrides the default for [ChipAttributes.shape],
  /// the shape of border to draw around the chip.
382 383 384 385 386 387 388 389 390 391 392
  ///
  /// This shape is combined with [side] to create a shape decorated with an
  /// outline. If it is a [MaterialStateOutlinedBorder],
  /// [MaterialStateProperty.resolve] is used for the following
  /// [MaterialState]s:
  ///
  ///  * [MaterialState.disabled].
  ///  * [MaterialState.selected].
  ///  * [MaterialState.hovered].
  ///  * [MaterialState.focused].
  ///  * [MaterialState.pressed].
393 394 395
  ///
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
396
  final OutlinedBorder? shape;
397

398 399 400
  /// Overrides the default for [ChipAttributes.labelStyle],
  /// the style of the [DefaultTextStyle] that contains the
  /// chip's label.
401 402 403
  ///
  /// This only has an effect on label widgets that respect the
  /// [DefaultTextStyle], such as [Text].
404 405 406 407
  ///
  /// This property applies to [ActionChip], [Chip],
  /// [FilterChip], [InputChip], [RawChip].
  final TextStyle? labelStyle;
408

409 410 411
  /// Overrides the default for [ChoiceChip.labelStyle],
  /// the style of the [DefaultTextStyle] that contains the
  /// chip's label.
412 413 414
  ///
  /// This only has an effect on label widgets that respect the
  /// [DefaultTextStyle], such as [Text].
415
  final TextStyle? secondaryLabelStyle;
416

417 418 419
  /// Overrides the default value for all chips which affects various base
  /// material color choices in the chip rendering.
  final Brightness? brightness;
420

421 422
  /// Overrides the default for [ChipAttributes.elevation],
  /// the elevation of the chip's [Material].
423
  ///
424 425
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
426
  final double? elevation;
427

428 429
  /// Overrides the default for [TappableChipAttributes.pressElevation],
  /// the elevation of the chip's [Material] during a "press" or tap down.
430
  ///
431
  /// This property applies to [ActionChip], [InputChip], [RawChip].
432
  final double? pressElevation;
433

434 435 436 437 438 439 440
  /// Overrides the default for [ChipAttributes.iconTheme],
  /// the theme used for all icons in the chip.
  ///
  /// This property applies to [ActionChip], [Chip], [ChoiceChip],
  /// [FilterChip], [InputChip], [RawChip].
  final IconThemeData? iconTheme;

441 442 443
  /// Creates a copy of this object but with the given fields replaced with the
  /// new values.
  ChipThemeData copyWith({
444
    MaterialStateProperty<Color?>? color,
445 446 447 448 449 450
    Color? backgroundColor,
    Color? deleteIconColor,
    Color? disabledColor,
    Color? selectedColor,
    Color? secondarySelectedColor,
    Color? shadowColor,
451
    Color? surfaceTintColor,
452
    Color? selectedShadowColor,
453
    bool? showCheckmark,
454 455 456
    Color? checkmarkColor,
    EdgeInsetsGeometry? labelPadding,
    EdgeInsetsGeometry? padding,
457 458
    BorderSide? side,
    OutlinedBorder? shape,
459 460 461 462 463
    TextStyle? labelStyle,
    TextStyle? secondaryLabelStyle,
    Brightness? brightness,
    double? elevation,
    double? pressElevation,
464
    IconThemeData? iconTheme,
465
  }) {
466
    return ChipThemeData(
467
      color: color ?? this.color,
468 469 470 471 472
      backgroundColor: backgroundColor ?? this.backgroundColor,
      deleteIconColor: deleteIconColor ?? this.deleteIconColor,
      disabledColor: disabledColor ?? this.disabledColor,
      selectedColor: selectedColor ?? this.selectedColor,
      secondarySelectedColor: secondarySelectedColor ?? this.secondarySelectedColor,
473
      shadowColor: shadowColor ?? this.shadowColor,
474
      surfaceTintColor: surfaceTintColor ?? this.surfaceTintColor,
475
      selectedShadowColor: selectedShadowColor ?? this.selectedShadowColor,
476
      showCheckmark: showCheckmark ?? this.showCheckmark,
477
      checkmarkColor: checkmarkColor ?? this.checkmarkColor,
478 479
      labelPadding: labelPadding ?? this.labelPadding,
      padding: padding ?? this.padding,
480
      side: side ?? this.side,
481 482 483 484
      shape: shape ?? this.shape,
      labelStyle: labelStyle ?? this.labelStyle,
      secondaryLabelStyle: secondaryLabelStyle ?? this.secondaryLabelStyle,
      brightness: brightness ?? this.brightness,
485 486
      elevation: elevation ?? this.elevation,
      pressElevation: pressElevation ?? this.pressElevation,
487
      iconTheme: iconTheme ?? this.iconTheme,
488 489 490 491 492 493 494
    );
  }

  /// Linearly interpolate between two chip themes.
  ///
  /// The arguments must not be null.
  ///
495
  /// {@macro dart.ui.shadow.lerp}
496
  static ChipThemeData? lerp(ChipThemeData? a, ChipThemeData? b, double t) {
497 498
    if (identical(a, b)) {
      return a;
499
    }
500
    return ChipThemeData(
501
      color: MaterialStateProperty.lerp<Color?>(a?.color, b?.color, t, Color.lerp),
502
      backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
503
      deleteIconColor: Color.lerp(a?.deleteIconColor, b?.deleteIconColor, t),
504 505 506
      disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t),
      selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t),
      secondarySelectedColor: Color.lerp(a?.secondarySelectedColor, b?.secondarySelectedColor, t),
507
      shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
508
      surfaceTintColor: Color.lerp(a?.surfaceTintColor, b?.surfaceTintColor, t),
509
      selectedShadowColor: Color.lerp(a?.selectedShadowColor, b?.selectedShadowColor, t),
510
      showCheckmark: t < 0.5 ? a?.showCheckmark ?? true : b?.showCheckmark ?? true,
511
      checkmarkColor: Color.lerp(a?.checkmarkColor, b?.checkmarkColor, t),
512
      labelPadding: EdgeInsetsGeometry.lerp(a?.labelPadding, b?.labelPadding, t),
513
      padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
514 515
      side: _lerpSides(a?.side, b?.side, t),
      shape: _lerpShapes(a?.shape, b?.shape, t),
516 517
      labelStyle: TextStyle.lerp(a?.labelStyle, b?.labelStyle, t),
      secondaryLabelStyle: TextStyle.lerp(a?.secondaryLabelStyle, b?.secondaryLabelStyle, t),
518
      brightness: t < 0.5 ? a?.brightness ?? Brightness.light : b?.brightness ?? Brightness.light,
519 520
      elevation: lerpDouble(a?.elevation, b?.elevation, t),
      pressElevation: lerpDouble(a?.pressElevation, b?.pressElevation, t),
521 522 523
      iconTheme: a?.iconTheme != null || b?.iconTheme != null
        ? IconThemeData.lerp(a?.iconTheme, b?.iconTheme, t)
        : null,
524 525 526
    );
  }

527 528
  // Special case because BorderSide.lerp() doesn't support null arguments.
  static BorderSide? _lerpSides(BorderSide? a, BorderSide? b, double t) {
529
    if (a == null && b == null) {
530
      return null;
531 532
    }
    if (a == null) {
533
      return BorderSide.lerp(BorderSide(width: 0, color: b!.color.withAlpha(0)), b, t);
534 535
    }
    if (b == null) {
536
      return BorderSide.lerp(BorderSide(width: 0, color: a.color.withAlpha(0)), a, t);
537
    }
538 539 540 541 542
    return BorderSide.lerp(a, b, t);
  }

  // TODO(perclasson): OutlinedBorder needs a lerp method - https://github.com/flutter/flutter/issues/60555.
  static OutlinedBorder? _lerpShapes(OutlinedBorder? a, OutlinedBorder? b, double t) {
543
    if (a == null && b == null) {
544
      return null;
545
    }
546 547 548
    return ShapeBorder.lerp(a, b, t) as OutlinedBorder?;
  }

549
  @override
550
  int get hashCode => Object.hashAll(<Object?>[
551
    color,
552 553 554 555 556 557
    backgroundColor,
    deleteIconColor,
    disabledColor,
    selectedColor,
    secondarySelectedColor,
    shadowColor,
558
    surfaceTintColor,
559
    selectedShadowColor,
560
    showCheckmark,
561 562 563 564 565 566 567 568 569 570
    checkmarkColor,
    labelPadding,
    padding,
    side,
    shape,
    labelStyle,
    secondaryLabelStyle,
    brightness,
    elevation,
    pressElevation,
571 572
    iconTheme,
  ]);
573 574 575 576 577 578 579 580 581

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }
582
    return other is ChipThemeData
583
        && other.color == color
584 585 586 587 588 589
        && other.backgroundColor == backgroundColor
        && other.deleteIconColor == deleteIconColor
        && other.disabledColor == disabledColor
        && other.selectedColor == selectedColor
        && other.secondarySelectedColor == secondarySelectedColor
        && other.shadowColor == shadowColor
590
        && other.surfaceTintColor == surfaceTintColor
591
        && other.selectedShadowColor == selectedShadowColor
592
        && other.showCheckmark == showCheckmark
593 594 595
        && other.checkmarkColor == checkmarkColor
        && other.labelPadding == labelPadding
        && other.padding == padding
596
        && other.side == side
597 598 599 600 601
        && other.shape == shape
        && other.labelStyle == labelStyle
        && other.secondaryLabelStyle == secondaryLabelStyle
        && other.brightness == brightness
        && other.elevation == elevation
602 603
        && other.pressElevation == pressElevation
        && other.iconTheme == iconTheme;
604 605 606 607 608
  }

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
609
    properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('color', color, defaultValue: null));
610 611 612 613 614 615
    properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: null));
    properties.add(ColorProperty('deleteIconColor', deleteIconColor, defaultValue: null));
    properties.add(ColorProperty('disabledColor', disabledColor, defaultValue: null));
    properties.add(ColorProperty('selectedColor', selectedColor, defaultValue: null));
    properties.add(ColorProperty('secondarySelectedColor', secondarySelectedColor, defaultValue: null));
    properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: null));
616
    properties.add(ColorProperty('surfaceTintColor', surfaceTintColor, defaultValue: null));
617
    properties.add(ColorProperty('selectedShadowColor', selectedShadowColor, defaultValue: null));
618
    properties.add(DiagnosticsProperty<bool>('showCheckmark', showCheckmark, defaultValue: null));
619 620 621 622 623 624 625 626 627 628
    properties.add(ColorProperty('checkMarkColor', checkmarkColor, defaultValue: null));
    properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('labelPadding', labelPadding, defaultValue: null));
    properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
    properties.add(DiagnosticsProperty<BorderSide>('side', side, defaultValue: null));
    properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
    properties.add(DiagnosticsProperty<TextStyle>('labelStyle', labelStyle, defaultValue: null));
    properties.add(DiagnosticsProperty<TextStyle>('secondaryLabelStyle', secondaryLabelStyle, defaultValue: null));
    properties.add(EnumProperty<Brightness>('brightness', brightness, defaultValue: null));
    properties.add(DoubleProperty('elevation', elevation, defaultValue: null));
    properties.add(DoubleProperty('pressElevation', pressElevation, defaultValue: null));
629
    properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, defaultValue: null));
630 631
  }
}