Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Added const constructor for color_converter.dart #12

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading