widgets library

Flutter layer: a controller and themed widgets over ChatGptClient.

Classes

CanvasDoc
A Canvas document extracted from a :::writing block.
CanvasDocument
A Canvas document arrived in the text channel.
ChatAnswer
Everything one turn produced, once it has finished.
ChatController
Drives a chat transcript. Plain ChangeNotifier, so it works with Riverpod, Bloc, Provider or a bare AnimatedBuilder — no state management imposed.
ChatEvent
Everything that can happen during one turn.
ChatGptClient
Entry point: creates sessions and owns the quota-rotation policy.
ChatGptSession
One anonymous conversation: a device id, a conversation id, and the turns exchanged so far. Overlapping send calls on one session are unsupported — create one session per concurrent conversation instead.
ChatGptStore
Where the package keeps the little state that should survive a restart: the device id and the current conversation id.
ChatMessage
One message in a conversation.
ChatMessageList
A scrolling transcript that sticks to the newest message.
ChatView
A complete chat screen over a ChatController.
Citation
A web source the assistant cited.
CitationChips
The sources behind an answer, one chip each.
CitationsReceived
Sources cited so far in this turn.
ConversationDetail
A conversation as the backend has it, fetched by id.
ConversationTitled
The backend named the conversation.
GenuiWidgetEvent
A generative-UI widget the backend emitted.
HttpTransport
The real transport, over package:http.
ImageGenerated
An image was generated. Anonymous sessions never see this — image_gen is a blocked feature — but the type exists so authenticated support is additive.
InMemoryStore
The default store. State lives as long as the process does.
Limits
Quota state, as reported inline on every turn.
MessageBubble
One message, aligned by role and coloured from the ambient theme.
MessageComposer
The input row: a text field and a send button.
ModelDowngraded
The backend answered with a different model than the one requested.
ModelInfo
A model as reported by the backend, with its real capabilities.
QuotaRotated
The session hit the hourly cap and switched to a fresh device id.
ReplyCompleted
The assistant finished writing, but the stream is still open.
SearchStarted
The backend ran web searches for this turn.
SendOptions
Per-turn options.
TextAttachment
A plain-text file attached to a turn. Binary files are not supported by the anonymous flow; extract text in your app first.
TextDelta
A chunk of assistant text, already stripped of PUA markers.
Transport
How the package reaches the backend. Swap it out in tests.
TurnCompleted
The turn finished.
TypingIndicator
Three pulsing dots shown while a reply streams.

Enums

ServiceTier
Upstream scheduling class. Only these two are accepted.
ThinkingEffort
How long a reasoning model deliberates. These three are the only values the backend accepts; anything else is HTTP 422.

Constants

kAnonPrefix → const String
Path prefix used by anonymous (no account) traffic.
kAppVersion → const String
App version reported in the User-Agent. Must match the sentinel payload era.
kBaseUrl → const String
Base host for the ChatGPT Android endpoint.
kSentinelPayload → const String
Static Play Integrity failure blob the Android client sends on every turn. Ported verbatim from chatgpt_client.py:119-128 — the backend accepts it as-is.
kServiceTiers → const Set<String>
The only values the backend accepts for service_tier.
kThinkingEfforts → const Set<String>
The only values the backend accepts for thinking_effort.

Functions

androidHeaders(String deviceId) Map<String, String>
Headers every request to the anonymous backend carries.
collectAnswer(Stream<ChatEvent> events) Future<ChatAnswer>
Everything a turn produced, awaited instead of streamed.
collectText(Stream<ChatEvent> events) Future<String>
The whole reply of a turn, as one string.
decodeJsonReply(String reply) Object?
Decodes a JSON reply, raising ProtocolException when it is not JSON.
extractJson(String reply) String
Pulls the JSON out of a reply that asked for JSON.
parseConversation(String body, {required String id}) ConversationDetail
Parses GET /backend-anon/conversation/{id} into a ConversationDetail.
stripPromptScaffolding(String text) String
Strips the scaffolding this package prepends to a user's prompt.

Exceptions / Errors

ChatGptException
Base type for every error this package raises.
InvalidRequestException
The backend rejected the request body (HTTP 422), or we rejected it first.
ProtocolException
The stream was well-delivered but not well-formed.
QuotaExceededException
The anonymous quota is spent and rotating to a fresh device did not help.
RateLimitedException
The backend returned 429. retryAfter is set when it told us when to return.
TransportException
The request never completed: DNS, TLS, socket, timeout.