NetworkAdapter class abstract

Abstract interface for network adapters in RxNet Plus.

This interface defines the standard contract that all network adapters must implement. Different HTTP client libraries (Dio, http, etc.) can be integrated by implementing this interface, allowing RxNet to work with any HTTP client seamlessly.

Built-in Adapters

RxNet Plus provides three built-in adapters:

  • DioAdapter: Full-featured adapter based on Dio (default)
  • HttpAdapter: Lightweight adapter based on dart:http
  • MockAdapter: Testing adapter with no network calls

Creating Custom Adapters

To create a custom adapter, implement this interface:

class MyCustomAdapter implements NetworkAdapter {
  @override
  String get name => 'MyCustomAdapter';

  @override
  String get version => '1.0.0';

  @override
  Future<AdapterResponse> request(AdapterRequest request) async {
    // Implement your HTTP logic here
  }

  // Implement other methods...
}

See also:

Implementers

Constructors

NetworkAdapter()

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
Gets the name of the adapter.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
version String
Gets the version of the adapter.
no setter

Methods

addInterceptor(AdapterInterceptor interceptor) → void
Adds an interceptor to the adapter.
cancel(CancelToken token) → void
Cancels an ongoing request.
download(AdapterRequest request, String savePath, {ProgressCallback? onProgress}) Future<AdapterResponse>
Downloads a file from the server.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeInterceptor(AdapterInterceptor interceptor) → void
Removes an interceptor from the adapter.
request(AdapterRequest request) Future<AdapterResponse>
Executes an HTTP request.
toString() String
A string representation of this object.
inherited
upload(AdapterRequest request, {ProgressCallback? onProgress}) Future<AdapterResponse>
Uploads data to the server.

Operators

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