1234567891011121314151617181920212223242526272829303132 |
- class UserModel {
- int id = 0;
- String userName = "";
- // String
- int sex = 0;
- int age = 18;
- UserModel({
- required this.id,
- required this.userName,
- required this.sex,
- required this.age,
- });
- static UserModel fromJson(Map<String, dynamic> json) {
- return UserModel(
- id: json['id'] ?? 0,
- userName: json['userName'] ?? "",
- sex: json['sex'] ?? 0,
- age: json['age'] ?? 18,
- );
- }
- Map<String, dynamic> toJson() {
- return {
- 'id': id,
- 'userName': userName,
- 'sex': sex,
- 'age': age,
- };
- }
- }
|