-
Notifications
You must be signed in to change notification settings - Fork 387
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
Allow annotated field with JsonKey.unknownEnumValue to be of type Map #1093
Comments
Same issue here |
The For the value the check can be passed when adding a case near https://github.com/google/json_serializable.dart/blob/master/json_serializable/lib/src/json_key_utils.dart#L164 like so: late DartType targetEnumType;
if (element.type.isEnum) {
targetEnumType = element.type;
} else if (coreIterableTypeChecker.isAssignableFromType(element.type)) {
targetEnumType = coreIterableGenericType(element.type);
} else if (coreMapTypeChecker.isAssignableFromType(element.type)) {
// Map handled here, index 1 denotes value type
targetEnumType = element.type.typeArgumentsOf(coreMapTypeChecker)![1];
} else {
throwUnsupported(
element,
'`$fieldName` can only be set on fields of type enum or on '
'Iterable, List, Set or Map instances of an enum type.',
);
} The code generated then already properly passes the given For the key one way would be implementing a |
At present, the #585 and PR #691 allows us to annotate
unknownEnumValue
fields of type enum or on Iterable, List, or Set instances of an enum type. Is is possible to support Map ?Example:
This is currently not possible. Enclosed error shown in terminal when generate the code
The text was updated successfully, but these errors were encountered: