fromJson method

  1. @override
DateTime? fromJson(
  1. Object? json
)
override

simple fromJson method, e.g. int.parse(json.toString) for an int value.

Implementation

@override
DateTime? fromJson(Object? json) {
  if (json == null) return null;
  switch (unit) {
    case CmsFilterDateEntryUnit.dateTime:
      return DateTime.parse(json as String);
    case CmsFilterDateEntryUnit.secondsSinceEpoch:
      return DateTime.fromMillisecondsSinceEpoch((json as int) * 1000);
    case CmsFilterDateEntryUnit.millisecondsSinceEpoch:
      return DateTime.fromMillisecondsSinceEpoch(json as int);
    case CmsFilterDateEntryUnit.microsecondsSinceEpoch:
      return DateTime.fromMicrosecondsSinceEpoch(json as int);
  }
}