12345678910111213141516171819202122232425262728293031323334 |
- class UserModel {
- late String token;
- late int id;
- late String nickname;
- late String avatarUrl;
- late bool isVip;
- late double wealth;
- late int coupon;
- late int monthlyTicket;
- UserModel.fromJson(Map json) {
- token = json['token'];
- id = json['id'];
- nickname = json['nickname'];
- avatarUrl = json['avatar'];
- isVip = json['is_vip'] == 1;
- wealth = json['wealth'];
- coupon = json['coupon'];
- monthlyTicket = json['ticket'];
- }
- Map<String, dynamic> toJson() {
- return {
- 'token': token,
- 'id': id,
- 'nickname': nickname,
- 'avatar': avatarUrl,
- 'is_vip': isVip ? 1 : 0,
- 'wealth': wealth,
- 'coupon': coupon,
- 'ticket': monthlyTicket,
- };
- }
- }
|