quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Replace `"` by `'` for the dart language

Open Hesamedin opened this issue 4 years ago • 1 comments

Please add an option in the Options list that let me replace " by '. This is the recommended notation by Dart.

For instance, this is the code generated by your interface:

class UsaState {
    UsaState({
        @required this.name,
        @required this.abbreviation,
    });

    final String name;
    final String abbreviation;

    factory UsaState.fromJson(Map<String, dynamic> json) => UsaState(
        name: json["name"],
        abbreviation: json["abbreviation"],
    );

    Map<String, dynamic> toJson() => {
        "name": name,
        "abbreviation": abbreviation,
    };
}

This is what it needs to be in Dart:

class UsaState {
  UsaState({
    @required this.name,
    @required this.abbreviation,
  });

  final String name;
  final String abbreviation;

  factory UsaState.fromJson(Map<String, dynamic> json) => UsaState(
        name: json['name'],
        abbreviation: json['abbreviation'],
      );

  Map<String, dynamic> toJson() => {
        'name': name,
        'abbreviation': abbreviation,
      };
}
``

Hesamedin avatar Jan 06 '21 19:01 Hesamedin

Single quotes are the standard. The tool should just generate single quotes.

freemansoft avatar Sep 17 '23 23:09 freemansoft