operator == method

  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 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 or return null.

  • 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;
  // Warning: make sure these properties are in the exact same order as in
  // hashValues() and in the raw constructor and in the order of fields in
  // the class and in the lerp() method.
  return other is ThemeData
      && other.visualDensity == visualDensity
      && other.primaryColor == primaryColor
      && other.primaryColorBrightness == primaryColorBrightness
      && other.primaryColorLight == primaryColorLight
      && other.primaryColorDark == primaryColorDark
      && other.accentColor == accentColor
      && other.accentColorBrightness == accentColorBrightness
      && other.canvasColor == canvasColor
      && other.scaffoldBackgroundColor == scaffoldBackgroundColor
      && other.bottomAppBarColor == bottomAppBarColor
      && other.cardColor == cardColor
      && other.shadowColor == shadowColor
      && other.dividerColor == dividerColor
      && other.highlightColor == highlightColor
      && other.splashColor == splashColor
      && other.splashFactory == splashFactory
      && other.selectedRowColor == selectedRowColor
      && other.unselectedWidgetColor == unselectedWidgetColor
      && other.disabledColor == disabledColor
      && other.buttonTheme == buttonTheme
      && other.buttonColor == buttonColor
      && other.toggleButtonsTheme == toggleButtonsTheme
      && other.secondaryHeaderColor == secondaryHeaderColor
      && other.textSelectionColor == textSelectionColor
      && other.cursorColor == cursorColor
      && other.textSelectionHandleColor == textSelectionHandleColor
      && other.backgroundColor == backgroundColor
      && other.dialogBackgroundColor == dialogBackgroundColor
      && other.indicatorColor == indicatorColor
      && other.hintColor == hintColor
      && other.errorColor == errorColor
      && other.toggleableActiveColor == toggleableActiveColor
      && other.textTheme == textTheme
      && other.primaryTextTheme == primaryTextTheme
      && other.accentTextTheme == accentTextTheme
      && other.inputDecorationTheme == inputDecorationTheme
      && other.iconTheme == iconTheme
      && other.primaryIconTheme == primaryIconTheme
      && other.accentIconTheme == accentIconTheme
      && other.sliderTheme == sliderTheme
      && other.tabBarTheme == tabBarTheme
      && other.tooltipTheme == tooltipTheme
      && other.cardTheme == cardTheme
      && other.chipTheme == chipTheme
      && other.platform == platform
      && other.materialTapTargetSize == materialTapTargetSize
      && other.applyElevationOverlayColor == applyElevationOverlayColor
      && other.pageTransitionsTheme == pageTransitionsTheme
      && other.appBarTheme == appBarTheme
      && other.bottomAppBarTheme == bottomAppBarTheme
      && other.colorScheme == colorScheme
      && other.dialogTheme == dialogTheme
      && other.floatingActionButtonTheme == floatingActionButtonTheme
      && other.navigationRailTheme == navigationRailTheme
      && other.typography == typography
      && other.cupertinoOverrideTheme == cupertinoOverrideTheme
      && other.snackBarTheme == snackBarTheme
      && other.bottomSheetTheme == bottomSheetTheme
      && other.popupMenuTheme == popupMenuTheme
      && other.bannerTheme == bannerTheme
      && other.dividerTheme == dividerTheme
      && other.buttonBarTheme == buttonBarTheme
      && other.bottomNavigationBarTheme == bottomNavigationBarTheme
      && other.timePickerTheme == timePickerTheme
      && other.textButtonTheme == textButtonTheme
      && other.elevatedButtonTheme == elevatedButtonTheme
      && other.outlinedButtonTheme == outlinedButtonTheme
      && other.textSelectionTheme == textSelectionTheme
      && other.dataTableTheme == dataTableTheme
      && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel
      && other.useTextSelectionTheme == useTextSelectionTheme;
}