Files
feature-next-arch/lib/core/app/app_state.dart
2026-01-11 19:42:22 +08:00

21 lines
542 B
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:equatable/equatable.dart';
import '../domain/entities/user_entity.dart';
class AppState extends Equatable {
final UserEntity? user; // 直接存实体,包含 userId, username,token 等所有信息
const AppState({this.user});
// 辅助属性:判断是否登录
bool get isLoggedIn => user != null;
AppState copyWith(UserEntity? user) {
return AppState(user: user ?? this.user);
}
// 必须重写 props,UI 才会只在数据真正变化时刷新
@override
List<Object?> get props => [user];
}