JsonRestApiClient class Null safety

Base class to create a json REST API client.

Constructors

JsonRestApiClient(Uri? baseUrl, {String? bearerToken, Client? httpClient})
Set the baseUrl and an optional bearerToken. Overwrite httpClient with a mock client for testing.

Properties

baseUrl Uri?
The base URL which will be the prefix for all requests.
read / write
bearerToken String?
If set, all requests will send this token in the Authorization header with Bearer $bearerToken.
read / write
hashCode int
The hash code for this object.
read-onlyinherited
httpClient Client
Handles the open connection to the server. Use this for additional tasks like uploading.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
request(RequestMethod method, String endpoint, {dynamic json, Map<String, dynamic>? queryParameters, Duration? timeout, Map<String, String> headers = const {}}) Future<JsonRestApiResponse>
Perform a request to the API which could either return json data or null. Set method to a valid http method like GET or POST and endpoint to one of the available endpoints of your api like /endpoint.
toString() String
A string representation of this object.
inherited

Operators

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