mobile_skt/lib/models/company.model.dart

43 lines
1.1 KiB
Dart
Raw Normal View History

import 'file.model.dart';
class CompanyModel {
CompanyModel({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.name,
required this.isDelete,
required this.files,
});
final int? id;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? name;
final int? isDelete;
final List<FileModel> files;
factory CompanyModel.fromJson(Map<String, dynamic> json) {
return CompanyModel(
id: json["id"],
createdAt: DateTime.tryParse(json["createdAt"] ?? ""),
updatedAt: DateTime.tryParse(json["updatedAt"] ?? ""),
name: json["name"],
isDelete: json["isDelete"],
files: json["files"] == null
? []
: List<FileModel>.from(
json["files"]!.map((x) => FileModel.fromJson(x))),
);
}
Map<String, dynamic> toJson() => {
"id": id,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
"name": name,
"isDelete": isDelete,
2024-03-31 17:13:29 +08:00
"files": files.map((x) => x.toJson()).toList(),
};
}