getDateTimeOrNull method

DateTime? getDateTimeOrNull(
  1. String key, {
  2. bool local = true,
})

Implementation

DateTime? getDateTimeOrNull(String key, {bool local = true}) {
  if (jsonObject.containsKey(key)) {
    String? validatedDate = validateString(jsonObject[key]);
    if (validatedDate != null) {
      return local
          ? DateTime.tryParse(validatedDate)?.toLocal()
          : DateTime.tryParse(validatedDate);
    }
  }
  return null;
}