class ElectricModel { String? fase; String? voltage; String? current; String? power; String? energy; String? pf; String? time; String? date; ElectricModel( {this.fase, this.voltage, this.current, this.power, this.energy, this.pf, this.time, this.date}); ElectricModel.fromJson(Map json) { fase = json['fase']; voltage = json['voltage']; current = json['current']; power = json['power']; energy = json['energy']; pf = json['pf']; time = json['time']; // just get the date only date = json['date'] == null ? '' : json['date'].substring(0, 10); } Map toJson() { final Map data = {}; data['fase'] = fase; data['voltage'] = voltage; data['current'] = current; data['power'] = power; data['energy'] = energy; data['pf'] = pf; data['time'] = time; data['date'] = date; return data; } }