Charlatan class
A class for building a collection of fake http responses to power a fake http client.
final charlatan = Charlatan()
..whenGet('/hero', (_) => <String, Object?>{'name': 'Bilbo'})
..whenGet('/sidekick', (_) => <String, Object?>{'name': 'Samwise'});
- Available extensions
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
findMatch(
CharlatanHttpRequest request) → CharlatanResponseDefinition? -
Returns the first fake response definition that matches the provided
request
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toFakeHttpClientAdapter(
) → CharlatanHttpClientAdapter -
Available on Charlatan, provided by the CharlatanExtensions extension
Builds a CharlatanHttpClientAdapter for a Charlatan instance. -
toPrettyPrintedString(
) → String - Prints a human-readable list of all the registered fake responses.
-
toString(
) → String -
A string representation of this object.
inherited
-
whenDelete(
String pathOrTemplate, CharlatanResponseBuilder responseBuilder) → void -
Adds a fake response definition for a DELETE request to the provided
pathOrTemplate
. If the response is not a CharlatanHttpResponse then thestatusCode
will be used. -
whenGet(
String pathOrTemplate, CharlatanResponseBuilder responseBuilder) → void -
Adds a fake response definition for a GET request to the provided
pathOrTemplate
. If the response is not a CharlatanHttpResponse then thestatusCode
will be used. -
whenMatch(
CharlatanRequestMatcher requestMatcher, CharlatanResponseBuilder responseBuilder, {String? description}) → void -
Adds a fake response definition for a request that matches the provided
requestMatcher
. If the response is not a CharlatanHttpResponse then thestatusCode
will be used. -
whenPost(
String pathOrTemplate, CharlatanResponseBuilder responseBuilder) → void -
Adds a fake response definition for a POST request to the provided
pathOrTemplate
. If the response is not a CharlatanHttpResponse then thestatusCode
will be used. -
whenPut(
String pathOrTemplate, CharlatanResponseBuilder responseBuilder) → void -
Adds a fake response definition for a PUT request to the provided
pathOrTemplate
. If the response is not a CharlatanHttpResponse then thestatusCode
will be used.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited