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

[Annotation Only] Adding case insensitive to enum based on loading JsonEnum config #1323

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

matanshukry
Copy link

Part of #1155 - see details here.

This is just the annotation part of the PR.

this.defaultValue,
this.disallowNullValue,
this.fromJson,
@Deprecated(
'Use `includeFromJson` and `includeToJson` with a value of `false` '
'instead.',
)
this.ignore,
this.ignore,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi this was done by dart format 🤷

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to be using a dev release of Dart 3.1 for this.

/// Specifically, both values will be lower-cased and compared.
///
/// Valid only on enum fields with a compatible enum value.
final bool caseInsensitive;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the option needed on both JsonEnum and JsonKey?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@t-beckmann so it can be used both at the enum level and at the field level.

Your question did make me add tests to the original PR, so I also found an issue and fixed it, and added 3 test cases: case insensitive on enum level, case insensitive on field level, and without any case insensitive (verifying behavior is same without it).

Example from the other PR:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants