api_apptimus 0.0.4 copy "api_apptimus: ^0.0.4" to clipboard
api_apptimus: ^0.0.4 copied to clipboard

A comprehensive Flutter package for simplifying API integration

ApiBaseRequests #

ApiBaseRequests is a class that provides methods to make HTTP requests to an API.

Usage #

Importing #

First, import the ApiBaseRequests class into your Dart file:

import 'package:moura_mobile/core/configs/api_config.dart';

Creating an instance #

Create an instance of ApiBaseRequests:

ApiBaseRequests apiBaseRequests = ApiBaseRequests();

Making GET Requests #

You can make GET requests using the get method:

var response = await apiBaseRequests.get('/api/example');
print(response); // Handle the response accordingly

Making POST Requests #

You can make POST requests using the post method:

var response = await apiBaseRequests.post('/api/example', data: {'key': 'value'});
print(response); // Handle the response accordingly

Handling Responses #

Responses are returned as dynamic objects. You can handle them according to your API's response structure.

**NetworkExceptions #

** NetworkExceptions is a class that provides methods to handle network exceptions that may occur during API requests.

Usage #

Importing First, import the NetworkExceptions class into your Dart file:

import 'package:moura_mobile/core/exceptions/network_exceptions.dart';

Handling Dio Exceptions You can handle Dio exceptions using the getDioException method:

try {
  // Make API request
} catch (e) {
  var networkException = NetworkExceptions.getDioException(e);
  print(networkException.message); // Handle the exception accordingly
}

Handling Other Exceptions #

You can handle other exceptions using the getDefaultException method:

try {
  // Make API request
} catch (e) {
  var networkException = NetworkExceptions.getDefaultException(e);
  print(networkException.message); // Handle the exception accordingly
}
3
likes
0
points
79
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter package for simplifying API integration

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, freezed_annotation

More

Packages that depend on api_apptimus