import 'dart:convert'; class Details { String name; String image; int unseenCount; String? lastMessage; DateTime? timeStamp; Details({ required this.name, required this.image, required this.lastMessage, required this.timeStamp, required this.unseenCount, }); factory Details.fromData(String _details) { return Details( name: json.decode(_details)['name'], image: json.decode(_details)['image'], lastMessage: json.decode(_details)['lastMessage'], timeStamp: DateTime.parse(json.decode(_details)['timeStamp'] ?? ""), unseenCount: json.decode(_details)['unseenCount'], ); } }