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.
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.
Works with
Packages commonly used together with rest_api_client: ones it builds on, ones built on it, and its own family.
- cryptorest_api_client depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- diorest_api_client depends on itA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.
- jwt_decoderrest_api_client depends on itDecode Json Web Tokens and check expiration status without a password.
- pretty_dio_loggerrest_api_client depends on itA Dio interceptor that logs network calls in a pretty, easy to read format.
- abstract_blocBuilt on rest_api_clientAbstract base classes and widgets for implementing BLoC pattern with pagination, items, and forms.