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.
aku_new_community/lib/models/home/home_announce_model.dart

44 lines
1.1 KiB

import 'package:aku_new_community/model/common/img_model.dart';
import 'package:common_utils/common_utils.dart';
import 'package:json_annotation/json_annotation.dart';
part 'home_announce_model.g.dart';
@JsonSerializable()
class HomeAnnounceModel {
final int id;
final String title;
final String content;
final List<ImgModel> imgList;
final String createDate;
factory HomeAnnounceModel.fromJson(Map<String, dynamic> json) =>
_$HomeAnnounceModelFromJson(json);
3 years ago
DateTime? get createDateDT => DateUtil.getDateTime(createDate);
int? get month => createDateDT?.month;
int? get year => createDateDT?.year;
const HomeAnnounceModel({
required this.id,
required this.title,
required this.content,
required this.imgList,
required this.createDate,
});
3 years ago
HomeAnnounceModel copyWith({
int? id,
String? title,
String? content,
List<ImgModel>? imgList,
String? createDate,
}) {
return HomeAnnounceModel(
id: id ?? this.id,
title: title ?? this.title,
content: content ?? this.content,
imgList: imgList ?? this.imgList,
createDate: createDate ?? this.createDate,
);
}
}