Message class

Available extensions

Constructors

Message({required String text, bool isUser = false, Uint8List? imageBytes, List<Uint8List> images = const [], Uint8List? audioBytes, MessageType type = MessageType.text, String? toolName, List<FunctionCallResponse> toolCalls = const [], String? toolCallId})
const
Message.audioOnly({required Uint8List audioBytes, bool isUser = false, String text = ''})
factory
Message.imageOnly({required Uint8List imageBytes, bool isUser = false, String text = ''})
factory
Message.imagesOnly({required List<Uint8List> imageBytes, bool isUser = false, String text = ''})
factory
Message.systemInfo({required String text, String? icon})
factory
Message.text({required String text, bool isUser = false})
factory
Message.thinking({required String text})
factory
Message.toolCall({String? text, List<FunctionCallResponse> calls = const []})
The model's tool call(s) in a history.
factory
Message.toolResponse({required String toolName, required Map<String, dynamic> response, String? toolCallId})
A tool result. toolCallId names the call it answers when that call had an id. No bundled engine reads it yet: the result is paired with its call by toolName, in order.
factory
Message.withAudio({required String text, required Uint8List audioBytes, bool isUser = false})
factory
Message.withImage({required String text, required Uint8List imageBytes, bool isUser = false})
factory
Message.withImages({required String text, required List<Uint8List> imageBytes, bool isUser = false})
factory

Properties

audioBytes → Uint8List?
final
hasAudio → bool
no setter
hashCode → int
The hash code for this object.
no setteroverride
hasImage → bool
no setter
imageBytes → Uint8List?
final
images → List<Uint8List>
final
isUser → bool
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
text → String
final
toolCallId → String?
The FunctionCallResponse.id a MessageType.toolResponse answers, or null when its call had none; ignored on any other type. No bundled engine reads it yet: a result is paired with its call by toolName, in order.
final
toolCalls → List<FunctionCallResponse>
The calls a MessageType.toolCall message carries, or empty when it was built from text alone; ignored on any other type. An engine reads them through toolCallsOf (package:flutter_edge_ai/engine.dart), which also parses text for a message saved with text alone. One model turn may be several consecutive toolCall messages (genai writes one per call, and a streamed text call is recorded as it completes); an engine that replays calls merges such a run into one turn.
final
toolName → String?
final
type → MessageType
final

Methods

copyWith({String? text, bool? isUser, Uint8List? imageBytes, List<Uint8List>? images, Uint8List? audioBytes, MessageType? type, String? toolName, List<FunctionCallResponse>? toolCalls, String? toolCallId}) → Message
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
transformToChatPrompt({ModelType type = ModelType.general, ModelFileType fileType = ModelFileType.binary}) → String

Available on Message, provided by the MessageExtension extension

Operators

operator ==(Object other) → bool
The equality operator.
override