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 List activeTasks; // 🔥 活跃任务列表(供用户选择) final bool isLoading; final String? errorMessage; final DeviceTaskOperationType operationType; final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗 const DeviceTaskState({ this.taskPool = const [], this.currentTask, this.currentTaskId, this.activeTasks = const [], // 🔥 默认空列表 this.isLoading = false, this.errorMessage, this.operationType = DeviceTaskOperationType.none, this.shouldShowError = false, }); DeviceTaskState copyWith({ List? taskPool, DeviceTaskEntity? currentTask, int? currentTaskId, List? activeTasks, // 🔥 新增 bool? isLoading, String? errorMessage, DeviceTaskOperationType? operationType, bool? shouldShowError, }) { return DeviceTaskState( taskPool: taskPool ?? this.taskPool, currentTask: currentTask ?? this.currentTask, currentTaskId: currentTaskId ?? this.currentTaskId, activeTasks: activeTasks ?? this.activeTasks, // 🔥 新增 isLoading: isLoading ?? this.isLoading, errorMessage: errorMessage, operationType: operationType ?? this.operationType, shouldShowError: shouldShowError ?? false, // 🔥 默认重置为 false ); } @override List get props => [ taskPool, currentTask, currentTaskId, activeTasks, // 🔥 新增 isLoading, errorMessage, operationType, shouldShowError, ]; }