user_config.dart 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // 用户相关的操作状态 State 类,用于 RiverPod 中 Provider 的定义
  2. class UserConfig {
  3. //用户的详情信息
  4. // UserProfile userProfile;
  5. //用户的登录Token
  6. String? token;
  7. //用户是否已经登录
  8. bool haslogin = false;
  9. //用户的 registrationId 推送标识
  10. String? registrationId;
  11. //用户的未读消息数量
  12. int unreadNotificationsCount = 0;
  13. // =================================== 插件自动生成-无需手动修改 ↓ ===================================
  14. //<editor-fold desc="Data Methods">
  15. UserConfig({
  16. this.token,
  17. required this.haslogin,
  18. required this.registrationId,
  19. required this.unreadNotificationsCount,
  20. });
  21. @override
  22. bool operator ==(Object other) =>
  23. identical(this, other) ||
  24. (other is UserConfig &&
  25. runtimeType == other.runtimeType &&
  26. token == other.token &&
  27. haslogin == other.haslogin &&
  28. registrationId == other.registrationId &&
  29. unreadNotificationsCount == other.unreadNotificationsCount);
  30. @override
  31. int get hashCode => token.hashCode ^ haslogin.hashCode ^ registrationId.hashCode ^ unreadNotificationsCount.hashCode;
  32. @override
  33. String toString() {
  34. return 'UserConfig{' +
  35. ' token: $token,' +
  36. ' haslogin: $haslogin,' +
  37. ' registrationId: $registrationId,' +
  38. ' unreadNotificationsCount: $unreadNotificationsCount,' +
  39. '}';
  40. }
  41. UserConfig copyWith({
  42. String? token,
  43. bool? haslogin,
  44. String? registrationId,
  45. int? unreadNotificationsCount,
  46. }) {
  47. return UserConfig(
  48. token: token ?? this.token,
  49. haslogin: haslogin ?? this.haslogin,
  50. registrationId: registrationId ?? this.registrationId,
  51. unreadNotificationsCount: unreadNotificationsCount ?? this.unreadNotificationsCount,
  52. );
  53. }
  54. Map<String, dynamic> toMap() {
  55. return {
  56. 'token': this.token,
  57. 'haslogin': this.haslogin,
  58. 'registrationId': this.registrationId,
  59. 'unreadNotificationsCount': this.unreadNotificationsCount,
  60. };
  61. }
  62. factory UserConfig.fromMap(Map<String, dynamic> map) {
  63. return UserConfig(
  64. token: map['token'] as String,
  65. haslogin: map['haslogin'] as bool,
  66. registrationId: map['registrationId'] as String,
  67. unreadNotificationsCount: map['unreadNotificationsCount'] as int,
  68. );
  69. }
  70. //</editor-fold>
  71. }