import 'package:equatable/equatable.dart'; import '../../domain/entities/device_task_entity.dart'; enum DeviceTaskOperationType { none, cancel, pause, recovery, } class DeviceTaskState extends Equatable { final List taskPool; final DeviceTaskEntity? currentTask; final int? currentTaskId; final bool isLoading; final String? errorMessage; final DeviceTaskOperationType operationType; final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗 const DeviceTaskState({ this.taskPool = const [], this.currentTask, this.currentTaskId, this.isLoading = false, this.errorMessage, this.operationType = DeviceTaskOperationType.none, this.shouldShowError = false, }); DeviceTaskState copyWith({ List? taskPool, DeviceTaskEntity? currentTask, int? currentTaskId, bool? isLoading, String? errorMessage, DeviceTaskOperationType? operationType, bool? shouldShowError, }) { return DeviceTaskState( taskPool: taskPool ?? this.taskPool, currentTask: currentTask ?? this.currentTask, currentTaskId: currentTaskId ?? this.currentTaskId, isLoading: isLoading ?? this.isLoading, errorMessage: errorMessage, operationType: operationType ?? this.operationType, shouldShowError: shouldShowError ?? false, // 🔥 默认重置为 false ); } @override List get props => [ taskPool, currentTask, currentTaskId, isLoading, errorMessage, operationType, shouldShowError, ]; }