CacheModel.fromMap constructor

CacheModel.fromMap(
  1. dynamic data
)

Implementation

factory CacheModel.fromMap(dynamic data) {
  try {
    if (data is Map<String, dynamic> &&
        (data['expirationDateTime'] != null || data['value'] != null)) {
      return CacheModel(
        expirationDateTime: dateTimeFromJson(data['expirationDateTime']),
        value: data['value'],
      );
    }
  } catch (e) {
    print(e);
  }

  return CacheModel(
    expirationDateTime: null,
    value: data,
  );
}