getDateTime method

DateTime? getDateTime({
  1. required String key,
  2. dynamic defaultValue,
})

Implementation

DateTime? getDateTime({required String key, dynamic defaultValue}) {
  dynamic value = getData(key: key);

  if (value == null) {
    return defaultValue;
  }

  if (value is String) {
    return DateTime.parse(value);
  }

  if (value is int) {
    return DateTime.fromMillisecondsSinceEpoch(value);
  }

  return defaultValue;
}