Skip to content

Commit

Permalink
Merge pull request #208 from cyrilcolinet/main
Browse files Browse the repository at this point in the history
chore: add missing switch case for AutovalidateMode.onUnfocus
  • Loading branch information
jpeiffer authored Sep 4, 2024
2 parents c4cc03a + f08555b commit 571b25d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 43 deletions.
5 changes: 5 additions & 0 deletions json_theme/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [6.5.1+1] - August 7th, 2024

* Add missing case AutovalidateMode.onUnfocus in encoder


## [6.5.0+1] - May 14th, 2024

* Swapped MaterialStateProperty with WidgetStateProperty in preperation for other Flutter 3.22 work.
Expand Down
19 changes: 2 additions & 17 deletions json_theme/lib/src/codec/theme_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,27 +238,12 @@ class ThemeEncoder {
return _stripDynamicNull(result);
}

/// Encodes the given [value] to a [String]. Supported values are:
/// * `always`
/// * `disabled`
/// * `onUserInteraction`
/// Encodes the given [value] to a [String].
static String? encodeAutovalidateMode(AutovalidateMode? value) {
String? result;

if (value != null) {
switch (value) {
case AutovalidateMode.always:
result = 'always';
break;

case AutovalidateMode.disabled:
result = 'disabled';
break;

case AutovalidateMode.onUserInteraction:
result = 'onUserInteraction';
break;
}
return value.name;
}

return _stripDynamicNull(result);
Expand Down
2 changes: 1 addition & 1 deletion json_theme/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'json_theme'
description: 'A library to dynamically generate a ThemeData object from a JSON file or dynamic map object'
homepage: 'https://github.com/peiffer-innovations/json_theme'
version: '6.5.0+1'
version: '6.5.1+1'

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
30 changes: 5 additions & 25 deletions json_theme/test/json_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,31 +495,11 @@ void main() {
AutovalidateMode.always,
);

expect(
ThemeDecoder.decodeAutovalidateMode('always'),
AutovalidateMode.always,
);
expect(
ThemeDecoder.decodeAutovalidateMode('disabled'),
AutovalidateMode.disabled,
);
expect(
ThemeDecoder.decodeAutovalidateMode('onUserInteraction'),
AutovalidateMode.onUserInteraction,
);

expect(
ThemeEncoder.encodeAutovalidateMode(AutovalidateMode.always),
'always',
);
expect(
ThemeEncoder.encodeAutovalidateMode(AutovalidateMode.disabled),
'disabled',
);
expect(
ThemeEncoder.encodeAutovalidateMode(AutovalidateMode.onUserInteraction),
'onUserInteraction',
);
// Test each values from AutovalidateMode enum
for (var value in AutovalidateMode.values) {
expect(ThemeDecoder.decodeAutovalidateMode(value.name), value);
expect(ThemeEncoder.encodeAutovalidateMode(value), value.name);
}
});

test('Axis', () {
Expand Down

0 comments on commit 571b25d

Please sign in to comment.