BduiHttpClient class abstract

Abstract HTTP client interface consumed by ApiWidget.

Implement this to provide a custom HTTP backend — useful for testing, mocking, or swapping in a different HTTP library without touching widget code.

class MockHttpClient implements BduiHttpClient {
  @override
  Future<ApiResponse> get(String url, {
    Map<String, String>? headers,
    Duration? cacheDuration,
    int? maxRetries,
    Duration? timeout,
  }) async {
    return ApiResponse(statusCode: 200, data: {'key': 'value'});
  }
  // implement remaining methods ...
}

ApiWidget(
  endpoint: '/products',
  httpClient: MockHttpClient(),
  successWidget: (data) => Text(data['key']),
)
Implementers

Constructors

BduiHttpClient()

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

delete(String url, {Map<String, String>? headers, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs a DELETE request.
execute(ApiRequest request) Future<ApiResponse>
Executes an ApiRequest — routes to the correct method based on ApiRequest.method. based on ApiRequest.method.
get(String url, {Map<String, String>? headers, Duration? cacheDuration, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs a GET request.
getWithRefresh(String url, {Map<String, String>? headers, Duration? cacheDuration, int? maxRetries, Duration? timeout, void onRefresh(ApiResponse freshResponse)?}) Future<ApiResponse>
Performs a GET request with stale-while-revalidate caching.
Performs a HEAD request — returns status and headers, no body.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
options(String url, {Map<String, String>? headers, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs an OPTIONS request — queries supported methods for an endpoint.
patch(String url, {Map<String, String>? headers, dynamic body, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs a PATCH request.
post(String url, {Map<String, String>? headers, dynamic body, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs a POST request.
put(String url, {Map<String, String>? headers, dynamic body, int? maxRetries, Duration? timeout}) Future<ApiResponse>
Performs a PUT request.
toString() String
A string representation of this object.
inherited

Operators

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