fromJson static method

MentorSettingsRequest? fromJson(
  1. dynamic value
)

Returns a new MentorSettingsRequest instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static MentorSettingsRequest? 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(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "MentorSettingsRequest[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MentorSettingsRequest[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MentorSettingsRequest(
      displayName: mapValueOfType<String>(json, r'display_name'),
      profileImage: mapValueOfType<String>(json, r'profile_image'),
      initialMessage: mapValueOfType<String>(json, r'initial_message'),
      suggestedMessage: mapValueOfType<String>(json, r'suggested_message'),
      theme: mapValueOfType<String>(json, r'theme'),
      userMessageColor: mapValueOfType<String>(json, r'user_message_color'),
      mentorBubbleColor: mapValueOfType<String>(json, r'mentor_bubble_color'),
      alignMentorBubble: mapValueOfType<String>(json, r'align_mentor_bubble'),
      systemPrompt: mapValueOfType<String>(json, r'system_prompt'),
      llmName: mapValueOfType<String>(json, r'llm_name'),
      featured: mapValueOfType<bool>(json, r'featured'),
      metadata: mapValueOfType<Object>(json, r'metadata'),
      customCss: mapValueOfType<String>(json, r'custom_css'),
      mentorVisibility: mapValueOfType<String>(json, r'mentor_visibility'),
      enableImageGeneration: mapValueOfType<bool>(json, r'enable_image_generation'),
      allowAnonymous: mapValueOfType<bool>(json, r'allow_anonymous'),
      mentorDescription: mapValueOfType<String>(json, r'mentor_description'),
    );
  }
  return null;
}