You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.5 KiB

import 'package:get/get.dart';
class Problem {
String? id;
String description;
String location;
List<String> 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<String, dynamic> toJson() {
return {
'id': id,
'description': description,
'location': location,
'imagePaths': imagePaths, // List<String> 类型可以直接序列化
'createdAt': createdAt.toIso8601String(),
'isUploaded': isUploaded, // bool 类型可以直接序列化
'boundInfo': boundInfo,
};
}
Map<String, dynamic> toMap() {
return {
'id': id,
'description': description,
'location': location,
'imagePaths': imagePaths.join(';;'),
'createdAt': createdAt.toIso8601String(),
'isUploaded': isUploaded ? 1 : 0,
'boundInfo': boundInfo,
};
}
factory Problem.fromMap(Map<String, dynamic> 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'],
);
}
}