Skip to content

Instantly share code, notes, and snippets.

@bardiarastin
Last active February 6, 2020 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bardiarastin/92a3d6bc6274fb074b6074004329830d to your computer and use it in GitHub Desktop.
Save bardiarastin/92a3d6bc6274fb074b6074004329830d to your computer and use it in GitHub Desktop.
class IPost {
int id;
int userId;
String title;
String body;
IPost.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
userId = json['userId'];
title = json['title'];
body = json['body'];
}
static List<IPost> listFromJson(List<dynamic> json) {
return json == null ? List<IPost>() : json.map((value) => IPost.fromJson(value)).toList();
}
}
@smhmayboudi
Copy link

I think it is a bad practice to write "I" for the class name or even the interface name.
https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#names

@bardiarastin
Copy link
Author

@smhmayboudi Yeah, you're right, but this is Dart and it's popular to do that

@smhmayboudi
Copy link

Sorry, my mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment