HttpSearchProvider
Category: Web
Source: http_search_provider.dart
Classes
SearchApiException
Error raised when a search provider's HTTP API returns a non-200 status.
Constructor
SearchApiException(this.message)Properties
| Property | Type | Description |
|---|---|---|
message | String |
Methods
String toString()
static String truncateBody(String body)
Truncates an HTTP error body to the first 200 chars for safe inclusion in an exception message. Shared by every HTTP-backed search provider.
HttpSearchRequest
Describes a single HTTP request a search provider issues to its backend.
A non-null [body] implies a POST; a null [body] implies a GET.
Constructor
HttpSearchRequest({required this.uri, required this.headers, this.body})Properties
| Property | Type | Description |
|---|---|---|
uri | Uri | |
headers | Map<String, String> | |
body | String? |
abstract HttpSearchProvider
Shared skeleton for API-key-backed HTTP search providers (Brave, Tavily, Firecrawl). Owns [isConfigured], the not-configured guard, the timeout, and the non-200 status check with 200-char body truncation.
Subclasses supply only [buildRequest] (request shape per query) and [parseResponseBody] (JSON → [WebSearchResponse]).
Constructor
HttpSearchProvider({
required this.apiKey,
this.timeoutSeconds = 15,
http.Client? client,
})Properties
| Property | Type | Description |
|---|---|---|
apiKey | String? | |
timeoutSeconds | int | |
apiLabel | String get | Human-readable provider label used in error messages (e.g. 'Brave Search API', 'Tavily API'). |
notConfiguredMessage | String get | Error message used when [isConfigured] is false. |
isConfigured | bool get | |
apiLabel | String get | Human-readable provider label used in error messages (e.g. 'Brave Search API', 'Tavily API'). |
notConfiguredMessage | String get | Error message used when [isConfigured] is false. |
isConfigured | bool get |
Methods
HttpSearchRequest buildRequest(String query, int maxResults)
Builds the HTTP request for [query] / [maxResults].
WebSearchResponse parseResponseBody(Map<String, dynamic> json, String query)
Maps a decoded JSON body to a [WebSearchResponse].