SanityClient class final

The client for fetching data from Sanity

Constructors

SanityClient(SanityConfig config, {Client? httpClient, UrlBuilder? urlBuilder})
Creates a new Sanity client with the provided configuration. Use the optional parameters to provide a custom HTTP client or URL builder.

Properties

config SanityConfig
The configuration for the client
final
hashCode int
The hash code for this object.
no setterinherited
httpClient ↔ Client
The HTTP client to use. Generally not needed to be provided. It can be set during testing or when used in the context of a framework that has its own http.Client instance.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
urlBuilder UrlBuilder
The URL builder to use. When not provided it uses the default Sanity URL builder
final

Methods

datasets() Future<List<SanityDataset>>
Fetches the associated datasets with this project
fetch(String query, {Map<String, String>? params}) Future<SanityQueryResponse>
Fetches data from Sanity by running the GROQ Query with the passed in parameters
fileUrl(String fileRefId) Uri
Return the associated object url
imageUrl(String imageRefId, {int? width, int? height, int? devicePixelRatio, int? quality, String? format}) Uri
Return the associated image url
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setHttpClient(Client client) → dynamic
Set the HTTP client to use for fetching data
toString() String
A string representation of this object.
inherited

Operators

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