From 38101fbeaeafec7cd8333b85757e68c51e7c2f85 Mon Sep 17 00:00:00 2001 From: benni-tec Date: Sat, 21 Dec 2024 10:05:32 +0100 Subject: [PATCH] added equality to ColorData --- packages/tiled/lib/src/common/color.dart | 10 ++++++++++ packages/tiled/pubspec.yaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/tiled/lib/src/common/color.dart b/packages/tiled/lib/src/common/color.dart index 7366d7b..f779a51 100644 --- a/packages/tiled/lib/src/common/color.dart +++ b/packages/tiled/lib/src/common/color.dart @@ -2,6 +2,7 @@ part of tiled; /// Basic data class holding a Color in ARGB format. /// This can be converted to dart:ui's Color using the flame_tiled package +@immutable class ColorData { static int _sub(int hex, int index) => (hex >> index * 8) & 0x000000ff; @@ -33,4 +34,13 @@ class ColorData { assert(alpha >= 0 && alpha <= 255), _hex = (alpha << 3 * 8) + (red << 2 * 8) + (green << 1 * 8) + (blue << 0 * 8); + + @override + bool operator ==(Object other) { + if (other is! ColorData) return false; + return _hex == other._hex; + } + + @override + int get hashCode => _hex.hashCode; } diff --git a/packages/tiled/pubspec.yaml b/packages/tiled/pubspec.yaml index af25f1c..abdb17b 100644 --- a/packages/tiled/pubspec.yaml +++ b/packages/tiled/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ">=2.18.0 <3.0.0" dependencies: - archive: ">=3.3.0 <5.0.0" + archive: ^4.0.2 collection: ^1.16.0 meta: ^1.7.0 xml: ^6.1.0