ApiKit class
The main class for handling API requests in flutter_api_kit.
Use this class to perform GET, POST, PUT, DELETE, and DOWNLOAD operations.
Constructors
- ApiKit()
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- baseUrl ↔ String
-
The base URL for all API requests.
getter/setter pair
-
defaultHeaders
→ Map<
String, dynamic> -
Default headers sent with every request.
no setter
Static Methods
-
clearToken(
) → void - Removes the Authorization token. Typically called during logout.
-
config(
{required String baseUrl, Map< String, dynamic> ? headers, Duration connectTimeout = const Duration(seconds: 30), Duration receiveTimeout = const Duration(seconds: 30), bool enableLogging = true}) → void - Global configuration for ApiKit.
-
delete(
{required BuildContext context, required String endpoint, Map< String, dynamic> ? queryParameters, Map<String, String> ? headers, bool showLoader = true, bool showErrorSnackbar = true, bool showSuccessSnackbar = true, String successMessage = 'Deleted successfully!', VoidCallback? onUnauthorized}) → Future<ApiResponse> - Performs a DELETE request.
-
download(
{required BuildContext context, required String url, required String savePath, String dialogTitle = 'Downloading...', bool showDialog = false, dynamic onProgress(double)?, VoidCallback? onComplete, dynamic onError(String)?, Color? progressColor, Color? progressBackgroundColor, TextStyle? titleStyle, ShapeBorder? dialogShape}) → Future< void> -
Downloads a file from
urltosavePath. -
get(
{required BuildContext context, required String endpoint, Map< String, dynamic> ? queryParameters, Map<String, String> ? headers, bool showLoader = true, bool showErrorSnackbar = true, bool showSuccessSnackbar = false, String successMessage = 'Done!', VoidCallback? onUnauthorized}) → Future<ApiResponse> - Performs a GET request.
-
post(
{required BuildContext context, required String endpoint, dynamic body, Map< String, dynamic> ? queryParameters, Map<String, String> ? headers, bool showLoader = true, bool showErrorSnackbar = true, bool showSuccessSnackbar = true, String successMessage = 'Saved successfully!', VoidCallback? onUnauthorized}) → Future<ApiResponse> - Performs a POST request.
-
put(
{required BuildContext context, required String endpoint, dynamic body, Map< String, dynamic> ? queryParameters, Map<String, String> ? headers, bool showLoader = true, bool showErrorSnackbar = true, bool showSuccessSnackbar = true, String successMessage = 'Updated successfully!', VoidCallback? onUnauthorized}) → Future<ApiResponse> - Performs a PUT request (Full Update).
-
setToken(
String token) → void - Sets the Authorization token for future requests. Typically called after a successful login.