URLSession class

A client that can make network requests to a server.

See NSURLSession

Constructors

URLSession.sessionWithConfiguration(URLSessionConfiguration config, {URLRequest? onRedirect(URLSession session, URLSessionTask task, HTTPURLResponse response, URLRequest newRequest)?, URLSessionResponseDisposition onResponse(URLSession session, URLSessionTask task, URLResponse response)?, void onData(URLSession session, URLSessionTask task, Data error)?, void onFinishedDownloading(URLSession session, URLSessionDownloadTask task, Uri uri)?, void onComplete(URLSession session, URLSessionTask task, Error? error)?, void onWebSocketTaskOpened(URLSession session, URLSessionWebSocketTask task, String? protocol)?, void onWebSocketTaskClosed(URLSession session, URLSessionWebSocketTask task, int? closeCode, Data? reason)?})
A client with a given configuration.
factory
URLSession.sharedSession()
A client with reasonable default behavior.
factory

Properties

configuration URLSessionConfiguration
A copy of the configuration for this session.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionDescription String?
A description of the session that may be useful for debugging.
getter/setter pair

Methods

dataTaskWithCompletionHandler(URLRequest request, void completion(Data? data, HTTPURLResponse? response, Error? error)) URLSessionTask
Creates a URLSessionTask that accesses a server URL and calls completion when done.
dataTaskWithRequest(URLRequest request) URLSessionTask
Create a URLSessionTask that accesses a server URL.
downloadTaskWithRequest(URLRequest request) URLSessionDownloadTask
Creates a URLSessionDownloadTask that downloads the data from a server URL.
finishTasksAndInvalidate() → void
Free resources related to this session after the last task completes. Returns immediately.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
webSocketTaskWithRequest(URLRequest request) URLSessionWebSocketTask
Creates a URLSessionWebSocketTask that represents a connection to a WebSocket endpoint.
webSocketTaskWithURL(Uri uri, {Iterable<String>? protocols}) URLSessionWebSocketTask
Creates a URLSessionWebSocketTask that represents a connection to a WebSocket endpoint.

Operators

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