networking_layer 1.0.0 copy "networking_layer: ^1.0.0" to clipboard
networking_layer: ^1.0.0 copied to clipboard

A robust, solid-compliant networking layer using Dio.

Networking Layer #

A robust, SOLID-compliant networking package for Flutter using Dio.

Features #

  • Decoupled Architecture: Independent of app-specific logic using DioConfig.
  • SOLID Principles: Clean separation of concerns.
  • Interceptors: Built-in support for Logging, Auth, Caching, and Retries.
  • GraphQL & REST: Unified ApiClient mixin for both.
  • Error Handling: Standardized HelperResponse with functional error handling (Either).

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  networking_layer:
    path: ./packages/networking_layer # If local
    # OR
    # git:
    #   url: https://github.com/your_username/networking_layer.git

Usage #

  1. Initialize DioServices in your main.dart:
void main() {
  DioServices.instance.init(
    DioConfig(
      baseUrl: 'https://api.example.com',
      getToken: () => 'your_token',
      translate: (key) => key, // Your cleanup logic
    ),
  );
  runApp(MyApp());
}
  1. Create a Repository using ApiClient:
class UserRepository with ApiClient {
  Future<Either<HelperResponse, User>> getUser(String id) async {
    return await get<User>(
      '/users/$id',
      fromJson: (json) => User.fromJson(json),
    );
  }
}

Example #

See example/lib/main.dart for a complete runnable example.

4
likes
0
points
274
downloads

Publisher

unverified uploader

Weekly Downloads

A robust, solid-compliant networking layer using Dio.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dartz, dio, equatable, flutter

More

Packages that depend on networking_layer