-
-
Save Rahiche/92ddfbdb7ca39dc3e4f810a576415e42 to your computer and use it in GitHub Desktop.
This file contains 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
/// ClientModel.dart | |
import 'dart:convert'; | |
Client clientFromJson(String str) { | |
final jsonData = json.decode(str); | |
return Client.fromMap(jsonData); | |
} | |
String clientToJson(Client data) { | |
final dyn = data.toMap(); | |
return json.encode(dyn); | |
} | |
class Client { | |
int id; | |
String firstName; | |
String lastName; | |
bool blocked; | |
Client({ | |
this.id, | |
this.firstName, | |
this.lastName, | |
this.blocked, | |
}); | |
factory Client.fromMap(Map<String, dynamic> json) => new Client( | |
id: json["id"], | |
firstName: json["first_name"], | |
lastName: json["last_name"], | |
blocked: json["blocked"] == 1, | |
); | |
Map<String, dynamic> toMap() => { | |
"id": id, | |
"first_name": firstName, | |
"last_name": lastName, | |
"blocked": blocked, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You are right
Thanks, I just updated the snippet