Skip to content

Commit

Permalink
Merge pull request #12 from DutchCodingCompany/fix/color_converter_const
Browse files Browse the repository at this point in the history
⚡ Added const constructor for color_converter.dart
  • Loading branch information
Guldem authored Oct 22, 2024
2 parents e7cfe5c + 1ccc6ec commit d8a8202
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/chopper/color_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import 'package:freezed_annotation/freezed_annotation.dart';

/// A class that implements JsonConverter to convert Color objects to and from JSON.
class ColorConverter implements JsonConverter<Color, String> {
/// A class that implements JsonConverter to convert Color objects to and from JSON.
const ColorConverter();

/// Converts a hexadecimal color string from JSON to a Color object.
///
/// The input string [json] is expected to be a hexadecimal color string.
Expand Down
4 changes: 2 additions & 2 deletions test/chopper/color_converter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
[const Color(0xFFFFFFFF), '#ffffffff'],
[const Color(0xF1F1F1F1), '#f1f1f1f1'],
], (Color color, String expected) {
final result = ColorConverter().toJson(color);
final result = const ColorConverter().toJson(color);

expect(result, expected);
});
Expand All @@ -25,7 +25,7 @@ void main() {
[const Color(0xF1F1F1F1), '#f1f1f1f1'],
[const Color(0xFFFFFFFF), '#ffffff'],
], (Color expected, String json) {
final result = ColorConverter().fromJson(json);
final result = const ColorConverter().fromJson(json);

expect(result, expected);
});
Expand Down

0 comments on commit d8a8202

Please sign in to comment.