operator == method Null safety

  1. @override
bool operator ==(
  1. Object other
)
override

The equality operator.

The default behavior for all Objects is to return true if and only if this object and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.

If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.

Implementation

@override
bool operator ==(Object other) {
  if (other.runtimeType != runtimeType) {
    return false;
  }
  return other is ThemeData &&
      // For the sanity of the reader, make sure these properties are in the same
      // order in every place that they are separated by section comments (e.g.
      // GENERAL CONFIGURATION). Each section except for deprecations should be
      // alphabetical by symbol name.

      // GENERAL CONFIGURATION
      other.applyElevationOverlayColor == applyElevationOverlayColor &&
      other.cupertinoOverrideTheme == cupertinoOverrideTheme &&
      mapEquals(other.extensions, extensions) &&
      other.inputDecorationTheme == inputDecorationTheme &&
      other.materialTapTargetSize == materialTapTargetSize &&
      other.pageTransitionsTheme == pageTransitionsTheme &&
      other.platform == platform &&
      other.scrollbarTheme == scrollbarTheme &&
      other.splashFactory == splashFactory &&
      other.useMaterial3 == useMaterial3 &&
      other.visualDensity == visualDensity &&
      // COLOR
      other.backgroundColor == backgroundColor &&
      other.bottomAppBarColor == bottomAppBarColor &&
      other.canvasColor == canvasColor &&
      other.cardColor == cardColor &&
      other.colorScheme == colorScheme &&
      other.dialogBackgroundColor == dialogBackgroundColor &&
      other.disabledColor == disabledColor &&
      other.dividerColor == dividerColor &&
      other.errorColor == errorColor &&
      other.focusColor == focusColor &&
      other.highlightColor == highlightColor &&
      other.hintColor == hintColor &&
      other.hoverColor == hoverColor &&
      other.indicatorColor == indicatorColor &&
      other.primaryColor == primaryColor &&
      other.primaryColorDark == primaryColorDark &&
      other.primaryColorLight == primaryColorLight &&
      other.scaffoldBackgroundColor == scaffoldBackgroundColor &&
      other.secondaryHeaderColor == secondaryHeaderColor &&
      other.selectedRowColor == selectedRowColor &&
      other.shadowColor == shadowColor &&
      other.splashColor == splashColor &&
      other.toggleableActiveColor == toggleableActiveColor &&
      other.unselectedWidgetColor == unselectedWidgetColor &&
      // TYPOGRAPHY & ICONOGRAPHY
      other.iconTheme == iconTheme &&
      other.primaryIconTheme == primaryIconTheme &&
      other.primaryTextTheme == primaryTextTheme &&
      other.textTheme == textTheme &&
      other.typography == typography &&
      // COMPONENT THEMES
      other.appBarTheme == appBarTheme &&
      other.bannerTheme == bannerTheme &&
      other.bottomAppBarTheme == bottomAppBarTheme &&
      other.bottomNavigationBarTheme == bottomNavigationBarTheme &&
      other.bottomSheetTheme == bottomSheetTheme &&
      other.buttonBarTheme == buttonBarTheme &&
      other.buttonTheme == buttonTheme &&
      other.cardTheme == cardTheme &&
      other.checkboxTheme == checkboxTheme &&
      other.chipTheme == chipTheme &&
      other.dataTableTheme == dataTableTheme &&
      other.dialogTheme == dialogTheme &&
      other.dividerTheme == dividerTheme &&
      other.drawerTheme == drawerTheme &&
      other.elevatedButtonTheme == elevatedButtonTheme &&
      other.expansionTileTheme == expansionTileTheme &&
      other.floatingActionButtonTheme == floatingActionButtonTheme &&
      other.listTileTheme == listTileTheme &&
      other.navigationBarTheme == navigationBarTheme &&
      other.navigationRailTheme == navigationRailTheme &&
      other.outlinedButtonTheme == outlinedButtonTheme &&
      other.popupMenuTheme == popupMenuTheme &&
      other.progressIndicatorTheme == progressIndicatorTheme &&
      other.radioTheme == radioTheme &&
      other.sliderTheme == sliderTheme &&
      other.snackBarTheme == snackBarTheme &&
      other.switchTheme == switchTheme &&
      other.tabBarTheme == tabBarTheme &&
      other.textButtonTheme == textButtonTheme &&
      other.textSelectionTheme == textSelectionTheme &&
      other.timePickerTheme == timePickerTheme &&
      other.toggleButtonsTheme == toggleButtonsTheme &&
      other.tooltipTheme == tooltipTheme &&
      // DEPRECATED (newest deprecations at the bottom)
      other.accentColor == accentColor &&
      other.accentColorBrightness == accentColorBrightness &&
      other.accentTextTheme == accentTextTheme &&
      other.accentIconTheme == accentIconTheme &&
      other.buttonColor == buttonColor &&
      other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
      other.primaryColorBrightness == primaryColorBrightness &&
      other.androidOverscrollIndicator == androidOverscrollIndicator;
}