user_info.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:json_annotation/json_annotation.dart';
  2. import 'location_info.dart';
  3. part 'user_info.g.dart';
  4. @JsonSerializable()
  5. class UserInfo {
  6. @JsonKey(name: 'friendId')
  7. final String id;
  8. @JsonKey(name: 'phone')
  9. final String phoneNumber;
  10. @JsonKey(name: 'remark')
  11. String? remark;
  12. @JsonKey(name: 'timestamp')
  13. final int? timestamp;
  14. @JsonKey(name: 'blockedHim')
  15. final bool? blockedHim;
  16. @JsonKey(name: 'blockedMe')
  17. final bool? blockedMe;
  18. @JsonKey(name: 'location')
  19. final LocationInfo? lastLocation;
  20. @JsonKey(name: 'virtual')
  21. final bool? virtual;
  22. final bool? isMine;
  23. UserInfo({
  24. required this.id,
  25. required this.phoneNumber,
  26. this.remark,
  27. this.timestamp,
  28. this.blockedHim,
  29. this.blockedMe,
  30. this.lastLocation,
  31. this.virtual,
  32. this.isMine,
  33. });
  34. factory UserInfo.fromJson(Map<String, dynamic> json) =>
  35. _$UserInfoFromJson(json);
  36. Map<String, dynamic> toJson() => _$UserInfoToJson(this);
  37. String getUserNickName() {
  38. return remark ?? phoneNumber;
  39. }
  40. }