MBDateElement constructor

MBDateElement({
  1. required Map<String, dynamic> dictionary,
})

Initializes a date element with the dictionary returned by the MBurger APIs.

  • Parameters:
    • dictionary: The dictionary returned by the APIs.

Implementation

factory MBDateElement({required Map<String, dynamic> dictionary}) {
  DateTime? date;
  if (dictionary['value'] is String) {
    DateFormat dateFormat = DateFormat('dd/MM/yyyy HH:mm');
    String dateString = dictionary['value'] as String;
    date = dateFormat.parse(dateString);
  }
  return MBDateElement._(
    dictionary: dictionary,
    date: date,
  );
}