Files
ttstd_family_care/lib/features/auth/domain/auth_state.dart
T

40 lines
1.0 KiB
Dart

/// 认证控制器状态。
///
/// 不可变状态对象:UI 通过 ref.watch 消费,一次性提示经由 [alert] 字段传递,
/// 展示后由 consumeAlert() 置空。
class AuthState {
const AuthState({
this.isLoading = false,
this.isSendingCode = false,
this.countdownSeconds = 0,
this.alert,
});
/// 登录 / 注册进行中。
final bool isLoading;
/// 发送验证码进行中。
final bool isSendingCode;
/// 验证码倒计时剩余秒数(>0 时按钮禁用)。
final int countdownSeconds;
/// 一次性提示文案,为 null 表示无提示。
final String? alert;
AuthState copyWith({
bool? isLoading,
bool? isSendingCode,
int? countdownSeconds,
String? alert,
bool clearAlert = false,
}) {
return AuthState(
isLoading: isLoading ?? this.isLoading,
isSendingCode: isSendingCode ?? this.isSendingCode,
countdownSeconds: countdownSeconds ?? this.countdownSeconds,
alert: clearAlert ? null : (alert ?? this.alert),
);
}
}