fromJson static method
Returns a new CustomConfigParameters instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CustomConfigParameters? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
return true;
}());
return CustomConfigParameters(
absoluteAndRelativeDates: mapValueOfType<bool>(json, r'absoluteAndRelativeDates'),
absoluteDates: mapValueOfType<bool>(json, r'absoluteDates'),
allowAnon: mapValueOfType<bool>(json, r'allowAnon'),
allowAnonFlag: mapValueOfType<bool>(json, r'allowAnonFlag'),
allowAnonVotes: mapValueOfType<bool>(json, r'allowAnonVotes'),
allowedLanguages: json[r'allowedLanguages'] is Iterable
? (json[r'allowedLanguages'] as Iterable).cast<String>().toList(growable: false)
: const [],
collapseReplies: mapValueOfType<bool>(json, r'collapseReplies'),
commentCountFormat: mapValueOfType<String>(json, r'commentCountFormat'),
commentHTMLRenderingMode: CommentHTMLRenderingMode.fromJson(json[r'commentHTMLRenderingMode']),
commentThreadDeleteMode: CommentThreadDeletionMode.fromJson(json[r'commentThreadDeleteMode']),
commenterNameFormat: CommenterNameFormats.fromJson(json[r'commenterNameFormat']),
countAboveToggle: mapValueOfType<int>(json, r'countAboveToggle'),
customCSS: mapValueOfType<String>(json, r'customCSS'),
defaultAvatarSrc: mapValueOfType<String>(json, r'defaultAvatarSrc'),
defaultSortDirection: SortDirections.fromJson(json[r'defaultSortDirection']),
defaultUsername: mapValueOfType<String>(json, r'defaultUsername'),
disableAutoAdminMigration: mapValueOfType<bool>(json, r'disableAutoAdminMigration'),
disableAutoHashTagCreation: mapValueOfType<bool>(json, r'disableAutoHashTagCreation'),
disableBlocking: mapValueOfType<bool>(json, r'disableBlocking'),
disableCommenterCommentDelete: mapValueOfType<bool>(json, r'disableCommenterCommentDelete'),
disableCommenterCommentEdit: mapValueOfType<bool>(json, r'disableCommenterCommentEdit'),
disableEmailInputs: mapValueOfType<bool>(json, r'disableEmailInputs'),
disableLiveCommenting: mapValueOfType<bool>(json, r'disableLiveCommenting'),
disableNotificationBell: mapValueOfType<bool>(json, r'disableNotificationBell'),
disableProfileComments: mapValueOfType<bool>(json, r'disableProfileComments'),
disableProfileDirectMessages: mapValueOfType<bool>(json, r'disableProfileDirectMessages'),
disableProfiles: mapValueOfType<bool>(json, r'disableProfiles'),
disableSuccessMessage: mapValueOfType<bool>(json, r'disableSuccessMessage'),
disableToolbar: mapValueOfType<bool>(json, r'disableToolbar'),
disableUnverifiedLabel: mapValueOfType<bool>(json, r'disableUnverifiedLabel'),
disableVoting: mapValueOfType<bool>(json, r'disableVoting'),
enableCommenterLinks: mapValueOfType<bool>(json, r'enableCommenterLinks'),
enableSearch: mapValueOfType<bool>(json, r'enableSearch'),
enableSpoilers: mapValueOfType<bool>(json, r'enableSpoilers'),
enableThirdPartyCookieBypass: mapValueOfType<bool>(json, r'enableThirdPartyCookieBypass'),
enableViewCounts: mapValueOfType<bool>(json, r'enableViewCounts'),
enableVoteList: mapValueOfType<bool>(json, r'enableVoteList'),
enableWYSIWYG: mapValueOfType<bool>(json, r'enableWYSIWYG'),
gifRating: GifRating.fromJson(json[r'gifRating']),
hasDarkBackground: mapValueOfType<bool>(json, r'hasDarkBackground'),
headerHTML: mapValueOfType<String>(json, r'headerHTML'),
hideAvatars: mapValueOfType<bool>(json, r'hideAvatars'),
hideCommentsUnderCountTextFormat: mapValueOfType<String>(json, r'hideCommentsUnderCountTextFormat'),
imageContentProfanityLevel: ImageContentProfanityLevel.fromJson(json[r'imageContentProfanityLevel']),
inputAfterComments: mapValueOfType<bool>(json, r'inputAfterComments'),
limitCommentsByGroups: mapValueOfType<bool>(json, r'limitCommentsByGroups'),
locale: mapValueOfType<String>(json, r'locale'),
maxCommentCharacterLength: mapValueOfType<int>(json, r'maxCommentCharacterLength'),
maxCommentCreatedCountPUPM: mapValueOfType<int>(json, r'maxCommentCreatedCountPUPM'),
noCustomConfig: mapValueOfType<bool>(json, r'noCustomConfig'),
mentionAutoCompleteMode: MentionAutoCompleteMode.fromJson(json[r'mentionAutoCompleteMode']),
noImageUploads: mapValueOfType<bool>(json, r'noImageUploads'),
allowEmbeds: mapValueOfType<bool>(json, r'allowEmbeds'),
allowedEmbedDomains: json[r'allowedEmbedDomains'] is Iterable
? (json[r'allowedEmbedDomains'] as Iterable).cast<String>().toList(growable: false)
: const [],
noStyles: mapValueOfType<bool>(json, r'noStyles'),
pageSize: mapValueOfType<int>(json, r'pageSize'),
readonly: mapValueOfType<bool>(json, r'readonly'),
noNewRootComments: mapValueOfType<bool>(json, r'noNewRootComments'),
requireSSO: mapValueOfType<bool>(json, r'requireSSO'),
enableFChat: mapValueOfType<bool>(json, r'enableFChat'),
enableResizeHandle: mapValueOfType<bool>(json, r'enableResizeHandle'),
restrictedLinkDomains: json[r'restrictedLinkDomains'] is Iterable
? (json[r'restrictedLinkDomains'] as Iterable).cast<String>().toList(growable: false)
: const [],
showBadgesInTopBar: mapValueOfType<bool>(json, r'showBadgesInTopBar'),
showCommentSaveSuccess: mapValueOfType<bool>(json, r'showCommentSaveSuccess'),
showLiveRightAway: mapValueOfType<bool>(json, r'showLiveRightAway'),
showQuestion: mapValueOfType<bool>(json, r'showQuestion'),
spamRules: SpamRule.listFromJson(json[r'spamRules']),
ssoSecLvl: SSOSecurityLevel.fromJson(json[r'ssoSecLvl']),
translations: mapCastOfType<String, String>(json, r'translations'),
useShowCommentsToggle: mapValueOfType<bool>(json, r'useShowCommentsToggle'),
useSingleLineCommentInput: mapValueOfType<bool>(json, r'useSingleLineCommentInput'),
voteStyle: VoteStyle.fromJson(json[r'voteStyle']),
widgetQuestionId: mapValueOfType<String>(json, r'widgetQuestionId'),
widgetQuestionResultsStyle: CommentQuestionResultsRenderingType.fromJson(json[r'widgetQuestionResultsStyle']),
widgetQuestionShowBreakdown: mapValueOfType<bool>(json, r'widgetQuestionShowBreakdown'),
widgetQuestionStyle: QuestionRenderingType.fromJson(json[r'widgetQuestionStyle']),
widgetQuestionWhenToSave: QuestionWhenSave.fromJson(json[r'widgetQuestionWhenToSave']),
widgetQuestionsRequired: CommentQuestionsRequired.fromJson(json[r'widgetQuestionsRequired']),
widgetSubQuestionVisibility: QuestionSubQuestionVisibility.fromJson(json[r'widgetSubQuestionVisibility']),
wrap: mapValueOfType<bool>(json, r'wrap'),
usersListLocation: UsersListLocation.fromJson(json[r'usersListLocation']),
usersListIncludeOffline: mapValueOfType<bool>(json, r'usersListIncludeOffline'),
ticketBaseUrl: mapValueOfType<String>(json, r'ticketBaseUrl'),
ticketKBSearchEndpoint: mapValueOfType<String>(json, r'ticketKBSearchEndpoint'),
ticketFileUploadsEnabled: mapValueOfType<bool>(json, r'ticketFileUploadsEnabled'),
ticketMaxFileSize: mapValueOfType<int>(json, r'ticketMaxFileSize'),
ticketAutoAssignUserIds: json[r'ticketAutoAssignUserIds'] is Iterable
? (json[r'ticketAutoAssignUserIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
tos: TOSConfig.fromJson(json[r'tos']),
);
}
return null;
}