import 'package:get/get.dart'; class Problem { String? id; String description; String location; List imagePaths; DateTime createdAt; bool isUploaded; String? boundInfo; // 添加可观察的选中状态 final RxBool isChecked = false.obs; Problem({ this.id, required this.description, required this.location, required this.imagePaths, required this.createdAt, this.isUploaded = false, this.boundInfo, }); // 添加 toJson 方法 Map toJson() { return { 'id': id, 'description': description, 'location': location, 'imagePaths': imagePaths, // List 类型可以直接序列化 'createdAt': createdAt.toIso8601String(), 'isUploaded': isUploaded, // bool 类型可以直接序列化 'boundInfo': boundInfo, }; } Map toMap() { return { 'id': id, 'description': description, 'location': location, 'imagePaths': imagePaths.join(';;'), 'createdAt': createdAt.toIso8601String(), 'isUploaded': isUploaded ? 1 : 0, 'boundInfo': boundInfo, }; } factory Problem.fromMap(Map map) { return Problem( id: map['id'], description: map['description'], location: map['location'], imagePaths: (map['imagePaths'] as String).split(';;'), createdAt: DateTime.parse(map['createdAt']), isUploaded: map['isUploaded'] == 1, boundInfo: map['boundInfo'], ); } }