import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; class SugarHistoryModel { String sugartText = ''; String sugarValue = ''; String fasting= ''; String postPrandial= ''; String date= ''; String displayDate=''; String actualDate=''; String sugarInfoId=''; DateTime dateForFilter=new DateTime.now(); SugarHistoryModel(); factory SugarHistoryModel.fromJson(Map json){ SugarHistoryModel rtvm = new SugarHistoryModel(); rtvm.sugartText = json['sugarCategory'].toString() ?? ''; rtvm.sugarValue = json['sugarValue'].toString() ?? ''; rtvm.fasting = json['fasting'].toString() ?? ''; rtvm.postPrandial = json['postPrandial'].toString() ?? ''; rtvm.date = json['createdAt'].toString() ?? ''; rtvm.actualDate = json['date'].toString() ?? ''; rtvm.sugarInfoId = json['sugarinfoid'].toString() ?? ''; //DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date); rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate); return rtvm; } }