Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
1.2 kB
1
Indexable
Never
message_model.dart

import 'package:sofor_cep/Models/message_info_model.dart';

class MessageModel {
  static List<MessageInfoModel> messages = [];
}

/////////////////////////////////////////////

message_info_model.dart :

class MessageInfoModel {
  List<String> participants;
  String receiver;
  String sender;
  String message;
  DateTime timeStamp;
  String conversationID;

  MessageInfoModel(
      {this.participants,
      this.receiver,
      this.sender,
      this.message,
      this.timeStamp,
      this.conversationID});

  MessageInfoModel.fromJson(Map<String, dynamic> json) {
    participants = json['participants'].cast<String>();
    receiver = json['receiver'];
    sender = json['sender'];
    message = json['message'];
    timeStamp = DateTime.parse(json['timeStamp']);
    conversationID = json['conversationID'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['participants'] = this.participants;
    data['receiver'] = this.receiver;
    data['sender'] = this.sender;
    data['message'] = this.message;
    data['timeStamp'] = this.timeStamp;
    data['conversationID'] = this.conversationID;
    return data;
  }
}