Skip to content
pubscout

rest_api_client

3.0.2, released 6 months ago by an unverified publisher

HTTP client for REST APIs with JWT authentication, automatic token refresh, and response caching.

WASM-readyUnverified publisher
$ flutter pub add rest_api_client
Source repository

What it does

Provides a production-ready HTTP client built on top of Dio that simplifies REST API communication. It handles JWT authentication, automatic token refresh strategies, request retries with exponential backoff, response caching, and typed exception handling.

AI-written summary of version 3.0.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a robust HTTP client with built-in JWT authentication and refresh token rotation.
  • Your app requires offline caching capabilities for REST API responses.
  • You want typed exceptions and global error stream handling for network requests.

Skip it when

  • You are working with GraphQL, WebSockets, or gRPC instead of REST.
  • You prefer writing raw Dio code without an opinionated client abstraction.

Strengths

  • Built-in JWT authentication management and automatic token refresh.
  • Configurable response caching and retry logic with exponential backoff.
  • Supports multiple platforms including iOS, Android, Web, and Desktop.

Weaknesses

  • Tied to a specific abstraction layer rather than using raw Dio or standard http directly.
  • Limited to REST API communication.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
5

Call RestApiClient.initFlutter() in main before initializing the client.

import 'package:rest_api_client/rest_api_client.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await RestApiClient.initFlutter();

  final client = RestApiClientImpl(
    options: RestApiClientOptions(
      baseUrl: 'https://api.example.com',
    ),
  );

  await client.init();

  final result = await client.get('/users');
  if (result.hasData) {
    print(result.data);
  }
}

Alternatives

Packages that do the same job and could replace rest_api_client.

  • http

    If you want a lightweight, standard package maintained by the Dart team for simple HTTP requests.

Works with

Packages commonly used together with rest_api_client: ones it builds on, ones built on it, and its own family.