Content class

Represents the content of an AI response, including its components (parts) and the role associated with it, such as "user" or "model".

Constructors

Content.new({List<Part>? parts, String? role})
Creates a new Content object with optional parts and role.
Content.fromJson(Map<String, dynamic> json)
Factory constructor to create a Content instance from a JSON object.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
parts List<Part>?
A list of Part objects that make up the content. Each Part can represent text, files, or binary data.
getter/setter pair
role String?
The role associated with this content, indicating who or what generated the content (e.g., "model" or "user").
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the Content object to a JSON object.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

jsonToList(List list) List<Content>
Converts a JSON list into a list of Content objects.