From bae0775253c8c07fdaf852031d12eabc77eb6ace Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Mon, 28 Aug 2023 18:50:39 +0200 Subject: [PATCH] fix(neon): override equality operators in NeonTheme Signed-off-by: Nikolas Rimikis --- .../neon/neon/lib/src/theme/branding.dart | 4 +--- .../neon/neon/lib/src/theme/color_scheme.dart | 4 +--- packages/neon/neon/lib/src/theme/dialog.dart | 4 +--- packages/neon/neon/lib/src/theme/neon.dart | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/neon/neon/lib/src/theme/branding.dart b/packages/neon/neon/lib/src/theme/branding.dart index 3f9fea47..02844f0b 100644 --- a/packages/neon/neon/lib/src/theme/branding.dart +++ b/packages/neon/neon/lib/src/theme/branding.dart @@ -58,9 +58,7 @@ class Branding { if (identical(this, other)) { return true; } - if (other.runtimeType != runtimeType) { - return false; - } + return other is Branding && name == other.name && logo == other.logo && legalese == other.legalese; } } diff --git a/packages/neon/neon/lib/src/theme/color_scheme.dart b/packages/neon/neon/lib/src/theme/color_scheme.dart index 77ab527c..e670dd52 100644 --- a/packages/neon/neon/lib/src/theme/color_scheme.dart +++ b/packages/neon/neon/lib/src/theme/color_scheme.dart @@ -50,9 +50,7 @@ class NeonColorScheme { if (identical(this, other)) { return true; } - if (other.runtimeType != runtimeType) { - return false; - } + return other is NeonColorScheme && other.primary == primary; } } diff --git a/packages/neon/neon/lib/src/theme/dialog.dart b/packages/neon/neon/lib/src/theme/dialog.dart index fccb0e22..8273d981 100644 --- a/packages/neon/neon/lib/src/theme/dialog.dart +++ b/packages/neon/neon/lib/src/theme/dialog.dart @@ -56,9 +56,7 @@ class NeonDialogTheme { if (identical(this, other)) { return true; } - if (other.runtimeType != runtimeType) { - return false; - } + return other is NeonDialogTheme && other.constraints == constraints; } } diff --git a/packages/neon/neon/lib/src/theme/neon.dart b/packages/neon/neon/lib/src/theme/neon.dart index 915bf8b0..fe18ced8 100644 --- a/packages/neon/neon/lib/src/theme/neon.dart +++ b/packages/neon/neon/lib/src/theme/neon.dart @@ -55,4 +55,23 @@ class NeonTheme extends ThemeExtension { dialogTheme: NeonDialogTheme.lerp(dialogTheme, other.dialogTheme, t), ); } + + @override + int get hashCode => Object.hashAll([ + branding, + colorScheme, + dialogTheme, + ]); + + @override + bool operator ==(final Object other) { + if (identical(this, other)) { + return true; + } + + return other is NeonTheme && + other.branding == branding && + other.colorScheme == colorScheme && + other.dialogTheme == dialogTheme; + } }