import 'package:json_annotation/json_annotation.dart'; part 'chat_item.g.dart'; @JsonSerializable() class ChatItem { @JsonKey(name: "id") final int id; @JsonKey(name: "chatId") final String conversationId; @JsonKey(name: "role") final String role; @JsonKey(name: "content") String content; @JsonKey(name: "createTime") final String createTime; ChatItem({ required this.id, required this.conversationId, required this.role, required this.content, required this.createTime, }); factory ChatItem.fromJson(Map json) => _$ChatItemFromJson(json); }