contact model for dummy working
This commit is contained in:
parent
451294ba08
commit
19d429d739
33
packages/simplex_app/lib/model/contact.dart
Normal file
33
packages/simplex_app/lib/model/contact.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Contact {
|
||||
final String? name;
|
||||
final String? msg;
|
||||
final String? msgTime;
|
||||
|
||||
Contact({this.name, this.msg, this.msgTime});
|
||||
|
||||
factory Contact.fromJson(Map<String, dynamic> json) {
|
||||
return Contact(
|
||||
name: json['name'], msg: json['msg'], msgTime: json['msgTime']);
|
||||
}
|
||||
|
||||
static Map<String, dynamic> toJson(Contact contact) {
|
||||
return {
|
||||
'name': contact.name,
|
||||
'msg': contact.msg,
|
||||
'msgTime': contact.msgTime,
|
||||
};
|
||||
}
|
||||
|
||||
static String encode(List<Contact> contacts) => json.encode(
|
||||
contacts
|
||||
.map<Map<String, dynamic>>((contact) => Contact.toJson(contact))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
static List<Contact> decode(String? contacts) =>
|
||||
(json.decode(contacts!) as List<dynamic>)
|
||||
.map<Contact>((item) => Contact.fromJson(item))
|
||||
.toList();
|
||||
}
|
Loading…
Reference in New Issue
Block a user