1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // 用户相关的操作状态 State 类,用于 RiverPod 中 Provider 的定义
- import 'package:domain/entity/user_me_entity.dart';
- class UserConfig {
- //用户的详情信息
- UserMeEntity? user;
- //用户的登录Token
- String? token;
- //用户姓名
- String? userName;
- //用户是否已经登录
- bool hasLogin = false;
- //用户的 registrationId 推送标识
- String? registrationId;
- //用户的未读消息数量
- int unreadNotificationsCount = 0;
- /// 获取用户默认的房产名称
- String? getDefaultEstateName() {
- return user?.estates
- ?.firstWhere(
- (estate) => estate.accounts?.any((a) => a.isDefault == 1) ?? false,
- orElse: () => UserMeEstates(), // 如果没有匹配项返回 null name
- )
- .name;
- }
- /// =================================== 插件自动生成-无需手动修改 ↓ ===================================
- //<editor-fold desc="Data Methods">
- UserConfig({
- this.user,
- this.token,
- this.userName,
- required this.hasLogin,
- this.registrationId,
- required this.unreadNotificationsCount,
- });
- UserConfig copyWith({
- UserMeEntity? user,
- String? token,
- String? userName,
- bool? hasLogin,
- String? registrationId,
- int? unreadNotificationsCount,
- }) {
- return UserConfig(
- user: user ?? this.user,
- token: token ?? this.token,
- userName: userName ?? this.userName,
- hasLogin: hasLogin ?? this.hasLogin,
- registrationId: registrationId ?? this.registrationId,
- unreadNotificationsCount: unreadNotificationsCount ?? this.unreadNotificationsCount,
- );
- }
- //</editor-fold>
- }
|