Files
flutterApp/lib/features/devices/presentation/bloc/device_task_state.dart

66 lines
1.9 KiB
Dart
Raw Normal View History

import 'package:equatable/equatable.dart';
import '../../domain/entities/device_task_entity.dart';
enum DeviceTaskOperationType {
none,
cancel,
pause,
recovery,
}
class DeviceTaskState extends Equatable {
final List<DeviceTaskEntity> taskPool;
final DeviceTaskEntity? currentTask;
final int? currentTaskId;
final List<DeviceTaskEntity> 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<DeviceTaskEntity>? taskPool,
DeviceTaskEntity? currentTask,
int? currentTaskId,
List<DeviceTaskEntity>? 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<Object?> get props => [
taskPool,
currentTask,
currentTaskId,
activeTasks, // 🔥 新增
isLoading,
errorMessage,
operationType,
shouldShowError,
];
}