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

_complex_from_json_required handle the null, so remove double checking for null in generated code #98

Closed
wants to merge 2 commits into from

Conversation

pmg1991
Copy link
Contributor

@pmg1991 pmg1991 commented Apr 27, 2024

Generated code :

  static List<String> fromJson_tags(Map<String, dynamic> json) {
    final _jsonData = json[r'tags'];
    if (_jsonData == null) {
      throw DeserialisationError(json, r'tags', r'',
          'tags field is null and is required to have a value');
    }
    return (_jsonData == null)
        ? []
        : ((dynamic data) {
            return (data as List<dynamic>).cast<String>();
          }(_jsonData));
  }

Expected code:

  static List<String> fromJson_tags(Map<String, dynamic> json) {
    final _jsonData = json[r'tags'];
    return (_jsonData == null)
        ? []
        : ((dynamic data) {
            return (data as List<dynamic>).cast<String>();
          }(_jsonData));
  }

@pmg1991 pmg1991 closed this Apr 27, 2024
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.

1 participant