Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Future<List> _getAllEvents(String lectid) async {
var url = "http://www.71slabsolution.com/appointmy/geteventslect.php";
final response = await http.post(url, body: {
"useridval": lectid.toString(),
});
List<Map> jsonData = json.decode(response.body);
List<Event> events = jsonData.map((data) => Event.fromJson(data));
Map<DateTime, List<String>> eventMap = {};
events.forEach((Event event) {
DateTime dateTime = DateTime.parse(event.eVTDT);
if (eventMap[dateTime] == null) {
eventMap[dateTime] = [event.eVTDETS];
} else {
eventMap[dateTime].add(event.eVTDETS);
}
});
return events;
}
class Event {
String mSG;
String eVTID;
String iDUSER;
String eVTDETS;
String eVTDT;
String eVTTIMEFROM;
String eVTTIMETO;
String eVTSTAT;
Event(
{this.mSG,
this.eVTID,
this.iDUSER,
this.eVTDETS,
this.eVTDT,
this.eVTTIMEFROM,
this.eVTTIMETO,
this.eVTSTAT});
Event.fromJson(Map<String, dynamic> json) {
mSG = json['MSG'];
eVTID = json['EVTID'];
iDUSER = json['IDUSER'];
eVTDETS = json['EVT_DETS'];
eVTDT = json['EVT_DT'];
eVTTIMEFROM = json['EVT_TIME_FROM'];
eVTTIMETO = json['EVT_TIME_TO'];
eVTSTAT = json['EVT_STAT'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['MSG'] = this.mSG;
data['EVTID'] = this.eVTID;
data['IDUSER'] = this.iDUSER;
data['EVT_DETS'] = this.eVTDETS;
data['EVT_DT'] = this.eVTDT;
data['EVT_TIME_FROM'] = this.eVTTIMEFROM;
data['EVT_TIME_TO'] = this.eVTTIMETO;
data['EVT_STAT'] = this.eVTSTAT;
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.