Skip to content

Commit d8a8202

Browse files
authored
Merge pull request #12 from DutchCodingCompany/fix/color_converter_const
⚡ Added const constructor for color_converter.dart
2 parents e7cfe5c + 1ccc6ec commit d8a8202

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/chopper/color_converter.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'package:freezed_annotation/freezed_annotation.dart';
44

55
/// A class that implements JsonConverter to convert Color objects to and from JSON.
66
class ColorConverter implements JsonConverter<Color, String> {
7+
/// A class that implements JsonConverter to convert Color objects to and from JSON.
8+
const ColorConverter();
9+
710
/// Converts a hexadecimal color string from JSON to a Color object.
811
///
912
/// The input string [json] is expected to be a hexadecimal color string.

test/chopper/color_converter_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void main() {
1212
[const Color(0xFFFFFFFF), '#ffffffff'],
1313
[const Color(0xF1F1F1F1), '#f1f1f1f1'],
1414
], (Color color, String expected) {
15-
final result = ColorConverter().toJson(color);
15+
final result = const ColorConverter().toJson(color);
1616

1717
expect(result, expected);
1818
});
@@ -25,7 +25,7 @@ void main() {
2525
[const Color(0xF1F1F1F1), '#f1f1f1f1'],
2626
[const Color(0xFFFFFFFF), '#ffffff'],
2727
], (Color expected, String json) {
28-
final result = ColorConverter().fromJson(json);
28+
final result = const ColorConverter().fromJson(json);
2929

3030
expect(result, expected);
3131
});

0 commit comments

Comments
 (0)