dio_helper_flutter 1.0.13 icon indicating copy to clipboard operation
dio_helper_flutter: ^1.0.13 copied to clipboard

A starting point for Dart libraries or applications.

dio helper #

dio helper class used to api calling get, post, delete, put.

var apiRepository = ApiRepository(ApiProvider(DioHelper(Dio())));
String mainUrl = 'https://api.first.org/data/v1/';

GET API #

apiRepository.getApi('${mainUrl}countries', success: (response) {},
    error: (error) {
   print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');
});

POST API #

apiRepository.postApi('${mainUrl}countries', success: (response) {},
    error: (error) {
   print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');
});

POST API WITH QUERY PARAMETER CALLING #

apiRepository.postApi('${mainUrl}countries',
    queryParameters: {}, //QUERY PARAMETER
    success: (response) {}, error: (error) {
  //GET THE ERROR FROM DioErrorEntity
    print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');
});

POST API WITH BODY (JSON) CALLING #

apiRepository.postApi('${mainUrl}countries', data: {}, success: (response) {},
    error: (error) {
     print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');
});

IMAGE / FILE UPLOAD USING MULTIPART POST API #

  FormData formData = FormData.fromMap({
    "name": "",
    "age": 1,
    "file": await MultipartFile.fromFile("./flutter.png", filename: "flutter.png"),
  });
  
  apiRepository.imageUpload('${mainUrl}countries',
      formData: formData,
      success: (response) {},
      error: (error) {
       print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');
  });

DIO HELPER CLASS GET THE ERROR #

   print('Error ${error.errorLanguageEntity!.defaultLanguage} ${error.statusCode}');

DIO ERROR #

const requestCancelError = 'Request cancellation';
const connectionTimeOutError = 'Connection timed out';
const requestTimeOutError = 'Request timed out';
const responseTimeOutError = 'Response timeout';
const checkInternetConnectionError = 'Check your internet connection';
const requestSyntaxError = 'Request syntax error';
const serverRefusedError = 'Server refused to execute';
const dataNotAvailableError = 'Data not available';
const requestForbiddenError = 'Request method is forbidden';
const serverInternalError = 'Server internal error';
const invalidRequestError = 'Invalid request';
const serverDownError = 'Server is down';
const notSupportHTTPError = 'Does not support HTTP protocol request';
const unknownMistakeError = 'Unknown mistake';
const unknownError = 'Unknown error';
2
likes
100
pub points
67%
popularity

Publisher

unverified uploader

A starting point for Dart libraries or applications.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

dartz, dio

More

Packages that depend on dio_helper_flutter