send method
Future<void>
send(
- String text, {
- List<PromptAttachment> attachments = const [],
})
override
Implementation
@override
Future<void> send(
String text, {
List<PromptAttachment> attachments = const [],
}) {
if (_disposed ||
_error != null ||
_promptId != null ||
_restoreId != null) {
return Future.error(StateError('Session is unavailable or busy'));
}
if (attachments.isNotEmpty) {
return Future.error(
UnsupportedError('Use runtime prompt attachment encoding explicitly'),
);
}
final id = _id();
_promptId = id;
final result = _pending[id] = Completer<void>();
_turn++;
try {
runtime.prompt(requestId: id, sessionId: sessionId, text: text);
} catch (error) {
_fail(error);
}
notifySessionChanged();
return result.future;
}