Skip to content

Commit

Permalink
added equality to ColorData
Browse files Browse the repository at this point in the history
  • Loading branch information
benni-tec committed Dec 21, 2024
1 parent d68fefc commit 38101fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/tiled/lib/src/common/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Check notice on line 40 in packages/tiled/lib/src/common/color.dart

View workflow job for this annotation

GitHub Actions / analyze

Statement should be on a separate line.

Try moving the statement to a new line. See https://dart.dev/diagnostics/always_put_control_body_on_new_line to learn more about this problem.
return _hex == other._hex;
}

@override
int get hashCode => _hex.hashCode;
}
2 changes: 1 addition & 1 deletion packages/tiled/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38101fb

Please sign in to comment.