Last active
February 6, 2020 19:00
-
-
Save bardiarastin/92a3d6bc6274fb074b6074004329830d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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