FakeTransport class final

A transport that returns scripted responses and records what it was asked.

Responses are returned in order; the last one repeats once the script runs out, so a test that retries does not have to script every attempt.

Constructors

FakeTransport(List<HttpResponse> responses)
Replays responses in order.
FakeTransport.json(Object body, {int status = 200})
Replays a single JSON response.
factory

Properties

callCount int
How many requests have been received.
no setter
hashCode int
The hash code for this object.
no setterinherited
lastRequest HttpRequest?
The most recent request, or null if there has been none.
no setter
requests List<HttpRequest>
Every request received, in order.
final
responses List<HttpResponse>
The scripted responses.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
throwOnAttempt Map<int, Object>
Errors to throw instead of returning a response, by attempt index.
final

Methods

bodyAt(int index) Map<String, dynamic>
The decoded JSON body of the request at index.
call(HttpRequest request) Future<HttpResponse>
The transport function to hand to a client.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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