api_service_plus 0.0.1 copy "api_service_plus: ^0.0.1" to clipboard
api_service_plus: ^0.0.1 copied to clipboard

A customizable API wrapper around Dio.

Api Service Wrapper

A lightweight and customizable API service wrapper built on top of Dio.

This package helps you handle common networking tasks such as authentication, token refresh, caching, logging, and retries without repeating boilerplate code.

โœจ Features

โœ… Attach access tokens automatically via tokenProvider

๐Ÿ”„ Auto refresh expired tokens with refreshTokenHandler

โ™ป๏ธ Retry failed requests with exponential backoff

๐Ÿ“ฆ Built-in caching using dio_cache_interceptor

๐Ÿชต Optional logging of requests & responses

โŒ Throws a clean ApiException for easy error handling

๐Ÿ“ฆ Installation

Add this to your pubspec.yaml:

dependencies: api_service_wrapper: ^0.0.1

Then run:

flutter pub get

๐Ÿš€ Usage

import 'package:api_service_wrapper/api_service_wrapper.dart';

void main() async { final api = ApiService( baseUrl: "https://jsonplaceholder.typicode.com", tokenProvider: () async => "your-access-token", refreshTokenHandler: () async => "new-access-token", addLogging: true, );

try { final response = await api.get("/posts/1"); print("Response data: ${response.data}"); } on ApiException catch (e) { print("API failed: $e"); } }

๐Ÿงช Error Handling

try { final response = await api.get("/users"); } on ApiException catch (e) { print("Error: ${e.message} (code: ${e.statusCode})"); }

๐Ÿ“œ Changelog

See CHANGELOG.md for release notes.

๐Ÿ“„ License

This project is licensed under the MIT License.

2
likes
130
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable API wrapper around Dio.

Documentation

API reference

License

MIT (license)

Dependencies

dio, dio_cache_interceptor, flutter

More

Packages that depend on api_service_plus