import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; class Duty { String date; String type; Map data; int order; Jiffy get jdate => Jiffy.parse(date, isUtc: true); Jiffy? get start => ((data["hdep"] ?? data["start"]) != null || type == "checkin") ? Jiffy.parse( "$date ${_addChar(data["hdep"] ?? data["start"] ?? data["time"])}", isUtc: true, pattern: "yyyy-MM-dd HH:mm") : null; Jiffy? get end { final Jiffy? out = ((data["hdes"] ?? data["end"]) != null || type == "checkout") ? Jiffy.parse( "$date ${_addChar(data["hdes"] ?? data["end"] ?? data["time"])}", isUtc: true, pattern: "yyyy-MM-dd HH:mm") : null; if (out != null && start != null && out.isBefore(start!)) { return out.add(days: 1); } else { return out; } } IconData get icon { if (type == "flight") { return Icons.flight_takeoff; } else if (type == "checkin") { return Icons.arrow_forward; } else if (type == "checkout") { return Icons.arrow_back; } else if (type == "dhlimo") { return Icons.airport_shuttle; } else if (type == "dhflight") { return Icons.flight_takeoff; } else if (type == "ground") { return Icons.folder; } else if (type == "credit") { return Icons.schedule; } else { return Icons.file_copy; } } compareTo(Duty d) {} Duty( {required this.date, required this.type, required this.data, this.order = 0}); } String _addChar(String str, {String char = ":", int pos = 2}) => "${str.substring(0, pos)}$char${str.substring(pos, 4)}";