ncc library

Classes

Abortable
An HTTP request that can be aborted before it completes.
AbortableMultipartRequest
A MultipartRequest which supports abortion using abortTrigger.
AbortableRequest
A Request which supports abortion using abortTrigger.
AbortableStreamedRequest
A StreamedRequest which supports abortion using abortTrigger.
BaseClient
An abstract base class that implements the ClientMethods interface, providing a foundation for custom HTTP clients.
BaseRequest
The base class for HTTP requests.
BaseResponse
The base class for HTTP responses.
BaseResponseWithUrl
A BaseResponse with a url field.
ByteStream
A stream of chunks of bytes representing a single piece of data.
Client
The interface for HTTP clients that take care of maintaining persistent connections across multiple requests to the same server.
ClientMethods
An abstract interface that defines the contract for an HTTP client.
ContentType
A MIME/IANA media type used as the value of the HttpHeaders.contentTypeHeader header.
GlobalNetworkObservable
Manages global network observers and tracks network state per client.
HttpHeaders
Headers for HTTP requests and responses.
InMemorySessionStateManager
An in-memory implementation of SessionStateManager.
MediaType
A class representing an HTTP media type, as used in Accept and Content-Type headers.
MultipartFile
A file to be uploaded as part of a MultipartRequest.
MultipartRequest
A multipart/form-data request.
NccClient
A base HTTP client that integrates network state management and response handling.
NetworkObserver
An abstract interface that defines the methods for observing network events and responses in the context of a BaseClient. Implementing this interface allows the observer to receive notifications about changes in network status, errors, and responses.
OnResponse
A class that encapsulates the details of an HTTP response received from a server. It includes various properties that describe the content and status of the response, such as the body, status code, and reason phrase.
Request
An HTTP request where the entire request body is known in advance.
Response
An HTTP response where the entire response body is known in advance.
SessionClient
Abstract class representing an HTTP client that handles session management, including token renewal and invalid session handling.
SessionStateManager
Abstract class for managing the state of a session, such as cookies.
StreamedRequest
An HTTP request where the request body is sent asynchronously after the connection has been established and the headers have been sent.
StreamedResponse
An HTTP response where the response body is received asynchronously after the headers have been received.

Enums

NetworkState
Enum representing the various states of the network.

Mixins

NetworkObservable
Mixin that observes network state changes and allows notifying observers when the network status or response changes.

Functions

delete(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP DELETE request with the given headers to the given URL.
get(Uri url, {Map<String, String>? headers}) Future<Response>
Sends an HTTP GET request with the given headers to the given URL.
Sends an HTTP HEAD request with the given headers to the given URL.
patch(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PATCH request with the given headers and body to the given URL.
post(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP POST request with the given headers and body to the given URL.
put(Uri url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
Sends an HTTP PUT request with the given headers and body to the given URL.
read(Uri url, {Map<String, String>? headers}) Future<String>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a String.
readBytes(Uri url, {Map<String, String>? headers}) Future<Uint8List>
Sends an HTTP GET request with the given headers to the given URL and returns a Future that completes to the body of the response as a list of bytes.
runWithClient<R>(R body(), Client clientFactory(), {ZoneSpecification? zoneSpecification}) → R
Runs body in its own Zone with the Client returned by clientFactory set as the default Client.

Typedefs

RequestSender = Future<Response> Function(Map<String, String> headers)
A typedef representing a function that sends an HTTP request using the provided headers and returns a Future<Response>.

Exceptions / Errors

ClientException
An exception caused by an error in a pkg/http client.
HttpException
NetworkAvailabilityException
Exception thrown when there is a network availability issue, such as when the device is offline or cannot reach the server.
NetworkException
A base class for all exceptions related to network errors.
NotLoggedInException
Exception thrown when the user is not logged in or when the session has expired, leading to unauthorized access issues.
RequestAbortedException
Thrown when an HTTP request is aborted.
ServerAvailabilityException
Exception thrown when the server is unavailable, typically when the server is down or unreachable.
SocketException
Exception thrown when a socket operation fails.