import 'package:get/get.dart'; class Problem { String? id; String description; String location; List imageUrls; DateTime createdAt; bool isUploaded; String? censorTaskId; String? bindData; // 添加可观察的选中状态 final RxBool isChecked = false.obs; Problem({ this.id, required this.description, required this.location, required this.imageUrls, required this.createdAt, this.censorTaskId, this.bindData, this.isUploaded = false, }); // copyWith 方法:根据字段和构造函数进行修正 Problem copyWith({ String? id, String? description, String? location, List? imageUrls, DateTime? createdAt, bool? isUploaded, String? censorTaskId, String? bindData, }) { return Problem( id: id ?? this.id, description: description ?? this.description, location: location ?? this.location, imageUrls: imageUrls ?? this.imageUrls, createdAt: createdAt ?? this.createdAt, isUploaded: isUploaded ?? this.isUploaded, censorTaskId: censorTaskId ?? this.censorTaskId, bindData: bindData ?? this.bindData, ); } // toMap 方法:修正键名,确保与 fromMap 保持一致 Map toMap() { return { 'id': id, 'description': description, 'location': location, 'imageUrls': imageUrls.join(';;'), // 使用正确的键名 'imageUrls' 'createdAt': createdAt.millisecondsSinceEpoch, 'isUploaded': isUploaded ? 1 : 0, 'censorTaskId': censorTaskId, 'bindData': bindData, // 使用正确的键名 'bindData' }; } // fromMap 方法:修正键名,确保与 toMap 保持一致 factory Problem.fromMap(Map map) { return Problem( id: map['id'], description: map['description'], location: map['location'], imageUrls: (map['imageUrls'] as String).split( ';;', ), // 使用正确的键名 'imageUrls' createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']), isUploaded: map['isUploaded'] == 1, censorTaskId: map['censorTaskId'], bindData: map['bindData'], // 使用正确的键名 'bindData' ); } }