fromJson method

  1. @override
UPreference fromJson(
  1. Map<String, dynamic> json
)

Implementation

@override
UPreference fromJson(Map<String, dynamic> json) {
  try {
    if (isAdultContentPref(json)) {
      return UPreference.adultContentPref(
        data: const AdultContentPrefConverter().fromJson(json),
      );
    }
    if (isContentLabelPref(json)) {
      return UPreference.contentLabelPref(
        data: const ContentLabelPrefConverter().fromJson(json),
      );
    }
    if (isSavedFeedsPref(json)) {
      return UPreference.savedFeedsPref(
        data: const SavedFeedsPrefConverter().fromJson(json),
      );
    }
    if (isSavedFeedsPrefV2(json)) {
      return UPreference.savedFeedsPrefV2(
        data: const SavedFeedsPrefV2Converter().fromJson(json),
      );
    }
    if (isPersonalDetailsPref(json)) {
      return UPreference.personalDetailsPref(
        data: const PersonalDetailsPrefConverter().fromJson(json),
      );
    }
    if (isFeedViewPref(json)) {
      return UPreference.feedViewPref(
        data: const FeedViewPrefConverter().fromJson(json),
      );
    }
    if (isThreadViewPref(json)) {
      return UPreference.threadViewPref(
        data: const ThreadViewPrefConverter().fromJson(json),
      );
    }
    if (isInterestsPref(json)) {
      return UPreference.interestsPref(
        data: const InterestsPrefConverter().fromJson(json),
      );
    }
    if (isMutedWordsPref(json)) {
      return UPreference.mutedWordsPref(
        data: const MutedWordsPrefConverter().fromJson(json),
      );
    }
    if (isHiddenPostsPref(json)) {
      return UPreference.hiddenPostsPref(
        data: const HiddenPostsPrefConverter().fromJson(json),
      );
    }
    if (isBskyAppStatePref(json)) {
      return UPreference.bskyAppStatePref(
        data: const BskyAppStatePrefConverter().fromJson(json),
      );
    }
    if (isLabelersPref(json)) {
      return UPreference.labelersPref(
        data: const LabelersPrefConverter().fromJson(json),
      );
    }

    return UPreference.unknown(data: json);
  } catch (_) {
    return UPreference.unknown(data: json);
  }
}