Skip to content

Dartpedia Chapter 9 mismatch between intro and code examples #7212

@letidev

Description

@letidev

Page URL

https://dart.dev/learn/tutorial/data-and-json

Page source

https://github.com/dart-lang/site-www/blob/main/src/content/learn/tutorial/data-and-json.md

Describe the problem

In the intro of the chapter is mentioned that dart:convert and jsonDecode will be used but neither of those is used in the code in the chapter.

In the intro is mentioned:

You'll use the dart:convert library, the jsonDecode function, and pattern matching.

But the whole chapter uses this approach:

  /// Returns a new [TitlesSet] instance and imports its values from a JSON map
  static TitlesSet fromJson(Map<String, Object?> json) {
    if (json case {
      'canonical': final String canonical,
      'normalized': final String normalized,
      'display': final String display,
    }) {
      return TitlesSet(
        canonical: canonical,
        normalized: normalized,
        display: display,
      );
    }
    throw FormatException('Could not deserialize TitleSet, json=$json');
  }

Expected fix

Either rewrite the intro to not mention dart:convert and jsonDecode, or rewrite the chapter's code examples to use them.

Additional context

No response

I would like to fix this problem.

  • I will try and fix this problem on dart.dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    from.page-issueReported in a reader-filed concern

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions