autopilot_api 2.0.0
autopilot_api: ^2.0.0 copied to clipboard
Zero dependency pure Dart API engine for Flutter with smart caching, retry, token refresh, multipart upload, download support and automatic parsing.
π AutoPilot API Zero-boilerplate smart API engine for Flutter β now Pure Dart β‘
Pure Dart β’ Zero Dependencies β’ No Dio β’ No http β’ No shared_preferences β’ Production Ready
π― Why AutoPilot?
Every Flutter project eventually faces the same problem:
repeated API boilerplate manual token handling retry logic everywhere duplicated error handling complex multipart uploads cache management headaches
AutoPilot solves all of this with a clean, beginner-friendly, production-ready API engine.
β‘ Why AutoPilot Is Different
Most API packages:
require heavy setup depend on multiple plugins force repository patterns need manual retry/cache/token handling become difficult for beginners
AutoPilot provides everything out of the box.
β Zero dependencies β Pure Dart networking β Automatic token injection β Built-in retry system β Smart caching β Multipart uploads β Auto parsing β Request deduplication β Production-ready architecture
β Traditional API Code Future<UserModel?> getUser() async { try { final request = await HttpClient() .getUrl(Uri.parse('$baseUrl/user'));
final response = await request.close();
if (response.statusCode == 200) {
final body = await response
.transform(utf8.decoder)
.join();
final json = jsonDecode(body);
return UserModel.fromJson(json['data']);
}
} catch (e) { rethrow; }
return null; } β AutoPilot Way final res = await api.get
if (res.isSuccess) { print(res.data); } else { print(res.message); } β¨ Features Feature Supported π GET, POST, PUT, PATCH, DELETE β π Multipart upload β β¬οΈ File download β π Auto token injection β π Auto token refresh β πΎ Smart memory cache β β‘ Request deduplication β π Retry with exponential backoff β π Internet connectivity check β π¦ Smart response parsing β π¨ Beautiful debug logs β π Runtime environment switching β π GetX / Bloc / Riverpod / Provider β π§ͺ Unit-test friendly β β‘ Zero dependencies β π₯ What's New in v2.0.0
AutoPilot is now built entirely using Dart SDK libraries.
No external networking package required.
β Removed External Packages Removed Package Replaced With http dart:io HttpClient shared_preferences Pure Dart local storage connectivity_plus Native socket lookup path Internal utilities mime Internal MIME resolver β‘ Zero Dependencies dependencies: autopilot_api: ^2.0.0
Thatβs it.
No dependency conflicts. No platform channels. No native setup. No plugin headaches.
π¦ Installation
Add this to your pubspec.yaml:
dependencies: autopilot_api: ^2.0.0
Then run:
flutter pub get π 60-Second Integration Step 1 β Initialize AutoPilot void main() async { WidgetsFlutterBinding.ensureInitialized();
await AutoPilotApi.init( baseUrl : 'https://api.example.com/v1', enableLogs : true, enableCache : true, );
runApp(const MyApp()); } Step 2 β Make Your First API Call final api = AutoPilotApi.instance;
final res = await api.get
if (res.isSuccess) { print(res.data); } else { print(res.message); }
Thatβs enough to start using AutoPilot in any Flutter project.
π Complete Beginner Flow Step 1 β Create Model class UserModel { final int id; final String name;
UserModel({ required this.id, required this.name, });
factory UserModel.fromJson(Map<String, dynamic> json) { return UserModel( id : json['id'], name : json['name'], ); } } Step 2 β Call API final res = await api.get
AutoPilot uses:
import 'dart:io';
Powered internally by:
HttpClient
No http package required.
π Token Management Save Access Token await AutoPilotApi.setToken(token); Save Access + Refresh Tokens await AutoPilotApi.setTokens( accessToken : accessToken, refreshToken : refreshToken, ); Logout await AutoPilotApi.clearTokens();
Tokens are stored using:
β‘ In-memory cache πΎ Pure Dart local storage π Auto Token Refresh await AutoPilotApi.init( enableTokenRefresh : true,
onRefreshToken : () async { final token = await refreshAuthToken(); return token; }, ); Refresh Flow Request β 401 Unauthorized β Refresh Token β Retry Original Request β Success β πΎ Smart Cache final res = await api.get( endpoint : '/config', useCache : true, cacheDuration : Duration(hours: 1), );
Supports:
β‘ Memory cache π½ Persistent disk cache π§ Automatic invalidation π Smart cache keys π Multipart Upload final res = await api.multipart( endpoint : '/upload',
files : [ MultipartFileModel( key : 'image', path : file.path, ), ], );
Supports:
Single file upload Multiple files Videos PDFs Form-data fields Custom MIME types β¬οΈ File Download final res = await api.download( endpoint : '/invoice.pdf', savePath : '/storage/downloads/invoice.pdf',
onProgress : (received, total) { final progress = received / total; print(progress); }, ); β‘ Request Deduplication await Future.wait([ api.get(endpoint: '/user'), api.get(endpoint: '/user'), api.get(endpoint: '/user'), ]);
β Only ONE request hits the server.
All callers receive the same response.
π Retry System await AutoPilotApi.init( maxRetries : 3, retryDelay : Duration(seconds: 1), ); Retry Flow Attempt 1 β Fail Attempt 2 β Fail Attempt 3 β Success β
Retries automatically on:
SocketException TimeoutException Temporary connection failures π¨ Beautiful Debug Logs ββββββββββββββββββββββββββββββββββββββββββββββ β π REQUEST [REQ-9A1F] β GET https://api.example.com/user ββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββ β β RESPONSE [REQ-9A1F] β Status: 200 β Time: 221ms ββββββββββββββββββββββββββββββββββββββββββββββ π¦ ApiResponse
Every request returns a strongly typed response object:
ApiResponse
β GetX β Bloc β Cubit β Riverpod β Provider β MobX β Vanilla setState
No adapters or wrappers required.
π Runtime Environment Switching api.reconfigure( (config) => config.copyWith( baseUrl: 'https://staging.api.com', ), );
Perfect for:
staging production testing QA environments π§ͺ Unit Testing Friendly flutter test
Supports:
Mock clients Fake responses Offline testing Parser testing π Performance Optimized β‘ Fast because: Persistent HttpClient In-memory token cache Request deduplication Smart retries Minimal allocations Zero reflection No platform channels π‘ Built-in Exceptions ApiException NetworkException TimeoutApiException UnauthorizedException ValidationException ServerException CacheException π API Reference Method Description get() GET request post() POST request put() PUT request patch() PATCH request delete() DELETE request multipart() Upload files download() Download files clearCache() Clear all cache invalidateCache() Remove endpoint cache setToken() Save access token clearTokens() Logout reconfigure() Runtime config update π₯ Perfect For Flutter beginners Production apps MVPs Admin panels E-commerce apps REST APIs Clean architecture projects GetX / Riverpod / Bloc apps β‘ Performance Comparison Feature Traditional APIs AutoPilot Boilerplate High Very Low Dependencies Multiple Zero Retry Manual Built-in Token Refresh Manual Automatic Cache Manual Built-in Multipart Upload Complex Simple Setup Time Long Minutes π― Why Developers Love AutoPilot
β Minimal boilerplate β Faster development β Production-ready architecture β Beginner-friendly API β Zero dependency conflicts β Smaller APK size β Faster compile times β Pure Dart performance
π License
MIT License Β© 2026 AutoPilot API
β Star on GitHub β’ π¦ Publish on pub.dev β’ π Build faster with AutoPilot