From 578118eb9d4268cf03acbedaa976929c7ab80041 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Tue, 22 Oct 2024 14:33:06 +0200 Subject: [PATCH 1/2] :zap: Added const constructor for color_converter.dart --- lib/chopper/color_converter.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/chopper/color_converter.dart b/lib/chopper/color_converter.dart index e768aff..30e9e83 100644 --- a/lib/chopper/color_converter.dart +++ b/lib/chopper/color_converter.dart @@ -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 { + /// 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. From 1ccc6ec4316e24206e033b79e093ef1c29d68fa2 Mon Sep 17 00:00:00 2001 From: Job Guldemeester Date: Tue, 22 Oct 2024 14:42:59 +0200 Subject: [PATCH 2/2] :white_check_mark: Added const constructors for tests --- test/chopper/color_converter_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/chopper/color_converter_test.dart b/test/chopper/color_converter_test.dart index 6f46a5d..185f4b3 100644 --- a/test/chopper/color_converter_test.dart +++ b/test/chopper/color_converter_test.dart @@ -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); }); @@ -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); });