api_utils library

Classes

ApiLogger
Add logging to your api calls in one place
ApiResponse<T>
Response from an api, with a typed data field

Functions

delete<T>({String url, Map<String, String> headers}) Future<ApiResponse<T>>
Make a DELETE request
get<T>({String url, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a GET request with a json object response
getByteArray({String url, Map<String, String> headers}) Future<ApiResponse<Uint8List>>
Make a GET request with a byte array response
getList<T>({String url, FromJson<T> fromJson, Map<String, String> headers}) Future<ApiResponse<List<T>>>
Make a GET request with an json list response
isSuccessStatusCode(int code) bool
patch<T>({String url, Map<String, dynamic> body, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a PATCH request sending a json object, with an optional json object response
post<T>({String url, Map<String, dynamic> body, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a POST request sending a json object, with an optional json object response
postAndGetList<T>({String url, Map<String, dynamic> body, FromJson<T> fromJson, Map<String, String> headers}) Future<ApiResponse<List<T>>>
Make a POST request sending a json object, with an optional json list response
postAsString<T>({String url, String body, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a POST request sending a raw string, with an optional json object response
put<T>({String url, Map<String, dynamic> body, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a PUT request sending a json object, with an optional json object response
putList<T>({String url, List body, FromJson<T> fromJson, bool useFromJsonOnFailure: false, Map<String, String> headers}) Future<ApiResponse<T>>
Make a PUT request sending a json list, with an optional json object response

Typedefs

FromJson<T>(Map<String, dynamic>) → T
OnError(String message, Exception e, StackTrace stack) → dynamic