user_model.dart 731 B

12345678910111213141516171819202122232425262728293031323334
  1. class UserModel {
  2. late String token;
  3. late int id;
  4. late String nickname;
  5. late String avatarUrl;
  6. late bool isVip;
  7. late double wealth;
  8. late int coupon;
  9. late int monthlyTicket;
  10. UserModel.fromJson(Map json) {
  11. token = json['token'];
  12. id = json['id'];
  13. nickname = json['nickname'];
  14. avatarUrl = json['avatar'];
  15. isVip = json['is_vip'] == 1;
  16. wealth = json['wealth'];
  17. coupon = json['coupon'];
  18. monthlyTicket = json['ticket'];
  19. }
  20. Map<String, dynamic> toJson() {
  21. return {
  22. 'token': token,
  23. 'id': id,
  24. 'nickname': nickname,
  25. 'avatar': avatarUrl,
  26. 'is_vip': isVip ? 1 : 0,
  27. 'wealth': wealth,
  28. 'coupon': coupon,
  29. 'ticket': monthlyTicket,
  30. };
  31. }
  32. }