AutoPilotApi class

🚀 AutoPilot API — Zero-boilerplate smart API engine. Only uses http + shared_preferences. No Dio. No extra deps.

// 1. Init once in main()
await AutoPilotApi.init(baseUrl: "https://api.example.com/v1");

// 2. Call anywhere — that's it!
final res = await AutoPilotApi.instance.get(
  endpoint : "/users/1",
  parser   : UserModel.fromJson,
);
if (res.isSuccess) print(res.data);
else print(res.message);

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCache() → Future<void>
delete<T>({required String endpoint, Map<String, dynamic>? body, T parser(dynamic json)?, Map<String, dynamic>? queryParams, Map<String, String>? headers}) → Future<ApiResponse<T>>
download({required String endpoint, required String savePath, Map<String, dynamic>? queryParams, void onProgress(int received, int total)?}) → Future<ApiResponse<String>>
get<T>({required String endpoint, T parser(dynamic json)?, Map<String, dynamic>? queryParams, Map<String, String>? headers, bool useCache = false, Duration? cacheDuration}) → Future<ApiResponse<T>>
invalidateCache(String endpoint, [Map<String, dynamic>? params]) → Future<void>
multipart<T>({required String endpoint, String? fileKey, String? filePath, List<MultipartFileModel>? files, Map<String, String>? fields, T parser(dynamic json)?, Map<String, String>? headers, void onProgress(int sent, int total)?}) → Future<ApiResponse<T>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
patch<T>({required String endpoint, Map<String, dynamic>? body, T parser(dynamic json)?, Map<String, dynamic>? queryParams, Map<String, String>? headers}) → Future<ApiResponse<T>>
post<T>({required String endpoint, Map<String, dynamic>? body, T parser(dynamic json)?, Map<String, dynamic>? queryParams, Map<String, String>? headers}) → Future<ApiResponse<T>>
put<T>({required String endpoint, Map<String, dynamic>? body, T parser(dynamic json)?, Map<String, dynamic>? queryParams, Map<String, String>? headers}) → Future<ApiResponse<T>>
reconfigure(AutoPilotConfig fn(AutoPilotConfig c)) → void
Switch environments at runtime.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → AutoPilotApi
no setter

Static Methods

clearTokens() → Future<void>
init({required String baseUrl, String tokenType = 'Bearer', int timeoutSeconds = 30, bool? enableLogs, bool enableCache = false, Duration cacheDuration = const Duration(minutes: 5), Map<String, String> globalHeaders = const {}, int maxRetries = 3, Duration retryDelay = const Duration(seconds: 1), bool enableTokenRefresh = false, Future<String?> onRefreshToken()?, bool enableGlobalLoader = false, void onLoadingChanged(bool loading)?, void onError(String message, int statusCode)?, void onRequestSent(String url, String method)?, void onResponseReceived(String url, int statusCode, Duration time)?, String successKey = 'status', dynamic successValue = true, String messageKey = 'message', String dataKey = 'data', bool enableDeduplication = true, bool printPayload = true, bool prettyPrint = true}) → Future<AutoPilotApi>
Initialize AutoPilot once at app startup.
setToken(String token) → Future<void>
setTokens({required String accessToken, required String refreshToken}) → Future<void>