Skip to content

Instantly share code, notes, and snippets.

@kmikko
Last active February 26, 2020 08:39
Show Gist options
  • Save kmikko/5809753ec112118a8fdcd9673f9d7c5c to your computer and use it in GitHub Desktop.
Save kmikko/5809753ec112118a8fdcd9673f9d7c5c to your computer and use it in GitHub Desktop.
import 'dart:convert';
void main() {
var jsonData = '{ "id": 1, "name": "Pena", "skills": ["C", "Java", "Kobol"] }';
User user = User.fromJson(jsonDecode(jsonData));
}
class User {
User(this.id, this.name, this.skills);
User.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
skills = List<String>.from(json['skills']);
final int id;
final String name;
final List<String> skills;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment