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

A package for handling API requests with Dio with cache functionality and auto cancel duplicate requests.

API Service #

A lightweight and efficient Dart/Flutter package for handling API requests with optional response caching. Ideal for apps that need consistent, streamlined API access with performance optimization via local cache storage.

✨ Features #

  • Simple API request handling using Dio
  • Built-in request caching support
  • Automatic duplicate request cancellation
  • Support for GET, POST, PUT, DELETE, and other HTTP methods
  • Easily pluggable into any Flutter project
  • Customizable cache expiry

πŸš€ Getting started #

Prerequisites #

  • Flutter 3.10+
  • Add api_service to your pubspec.yaml:
dependencies:
  api_service:
    path: ../path_to/api_service

Initialization #

ApiService.initialize(
  baseUrl: 'https://api.example.com',
  enableLogging: true,
  cacheEnabled: true,
);

πŸ“¦ Usage #

final response = await ApiService.get('/users', queryParameters: {
  'page': 1,
});

// Optional: Clear specific cache
ApiService.clearCache('/users');

// Optional: Refresh request
final refreshed = await ApiService.get('/users', forceRefresh: true);

πŸ“ Example #

See the /example directory for a working Flutter integration demo.

πŸ“š Additional information #

  • This package uses Hive for caching (can be extended to other solutions).
  • Issues and contributions are welcome.
  • For suggestions or help, reach out to the package maintainer.
4
likes
0
points
51
downloads

Publisher

verified publisherinnovationnxt.com

Weekly Downloads

A package for handling API requests with Dio with cache functionality and auto cancel duplicate requests.

License

unknown (license)

Dependencies

dio, flutter, hive, hive_flutter, path_provider

More

Packages that depend on api_request_handler