flutter_api_request

Last updated:

0 purchases

flutter_api_request Image
flutter_api_request Images
Add to Cart

Description:

flutter api request

Using this package to easily call rest apis and get a response.
Features #

With minimal parameters to call REST APIs
Handing exception

Getting started #

import ApiCallBackListener

import 'package:flutter_api_request/api/ApiCallBackListener.dart';
import 'package:flutter_api_request/api/ApiRequest.dart';
import 'package:flutter_api_request/api/HttpMethods.dart';
copied to clipboard

implement ApiCallBackListener

class _MyHomePageState extends State<MyHomePage> implements ApiCallBackListener{


//override apiCallBackListener
@override
apiCallBackListener(String apiAction, result) {
// TODO: implement apiCallBackListener

throw UnimplementedError();
}
}
copied to clipboard
Usage #

call REST apis

apiCall() {
ApiRequest(
context: context,
apiCallBackListener: this,
showLoader: true,
httpType: HttpMethods.POST,
url: "https://abc.cmsbox.in/api/connectionList",
apiAction: "CONNECTION_LIST",
logoutFunction: logout,
headers: CommonFile.getApiHeader("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiYjU5OWVmYTdlZDBmNTNlZDAwM2Q5NDQzNDk2NTYyZWU1Njk2NjIxMDA0MzRlMzI1NWIxZTcyYTYzZjAwMWJlOTkyNDA4NzA3ZmQxY2ZkMTQiLCJpYXQiOjE2NTg4MTY3MTYuMTU0MDY3MDM5NDg5NzQ2MDkzNzUsIm5iZiI6MTY1ODgxNjcxNi4xNTQwNzEwOTI2MDU1OTA4MjAzMTI1LCJleHAiOjE2OTAzNTI3MTYuMTQ3NDgwOTY0NjYwNjQ0NTMxMjUsInN1YiI6IjMiLCJzY29wZXMiOltdfQ.vnS-fkZhMIlaRNRzgyuFuaK4Va-w7jftlfDBPLtsfRoLE8pNpsCr78THxtNQyQaal0Cg3VyvVU1I2Bj5JBYvCQcAZ5IPcgS7kRhvk7E_yJYrKcZ_ODXdpk5OcmQzJ6wS0_srItzoDmKYIhlk8MYrLuNWGcDJTVEyxVNCCsB4WlwWKxuaPE40WVRYEUe1yfZRK--n9NUVsbFWkdXiSIQC-8ibZ93wmJxGbdbDfleHipoN9pFwMN-K4ogOtK7Dtf8R0qgaOFpu1z-DoBSJ8aqZNH__pKWbTFH67PGQRo9f1IWeW_ylGOgVnbwGmDMO-qJ4YC0x6CsUyR0XXzhpy-08oZ7HwnX8Bu_TN6x4SbYuSZ3kmdmr-_Ajjol562Yq1g9E3ZusluGyFXX7QCzMDY9hdH_tOHrvFrS4YuR4jTbbHoPMKpCLriIicW5_l3fhAmvd2AfP0gL5Z33remIbQTzKeg4DfomkIRc2-JaxgurPXUlm-e7wKlEOdVvMbJeXwnJUnFTcNpI9wbI2IMvO2IZIcNFuYrNGa9e3KU2FEiwb5OXpHTvcVn1HlAp2FxfYx3jczMO9FXRwqD15t-E43vl6Tsw6ET0qzWljFMV8PZdxfpA0tZ_fjrmBfmTkQmqVJKfT0X2AORP-IZM2wG1KOORjp__N4TsWI2dLrmr7S3ykbkA")
);
}
copied to clipboard

call REST apis for multipart

apiCall() {
Map<String, File> mapOfFilesAndKey = Map();
if (isFileExist(file)) {
mapOfFilesAndKey["cover_picture"] = file;
}

ApiRequest(
context: context,
apiCallBackListener: this,
showLoader: true,
httpType: HttpMethods.POST,
url: "https://abc.cmsbox.in/api/updateCoverProfile",
apiAction: "UpdateCoverProfile",
isMultiPart: true,
mapOfFilesAndKey: mapOfFilesAndKey,
headers: CommonFile.getApiHeader("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiNGZhM2U2MjY0OTZmZTg3OWZmZTIyNWFmMWQ5OWQ5ZjdlYjc1ZTA2NTA5M2MxZDVkOWNhMzAyYTA1ZjRiMDc2YzhjNTE4MzNkY2EwOWRjYWUiLCJpYXQiOjE2NTg0NzUyNjAuMjA4Mzg2ODk4MDQwNzcxNDg0Mzc1LCJuYmYiOjE2NTg0NzUyNjAuMjA4Mzg5OTk3NDgyMjk5ODA0Njg3NSwiZXhwIjoxNjkwMDExMjYwLjIwNDYyNDg5MTI4MTEyNzkyOTY4NzUsInN1YiI6IjI3Iiwic2NvcGVzIjpbXX0.QnwIpVW4U1UnhJeMc3HmZgsEayBQ4Qo7H1ddpzt8jzrEPSObwPe82OLvRRrgdB6W57KPmPmy72zPHlFNhXg2aRPK72KWqPNsalX1YQSg4ZQEuHXMNrrsR949-ecLeVm0vwaFxC0hMzsxCwBjcXLxZLl1n0s2xtdfdsSy8w3mdP7vhlWeWruFTkW7RAd8h6gcnHpBDjma-JaCU0pfjVaJ1WD1SEuR2LTvXPCypJpeA7XJ0qZ23dEaDl3bymeL7fmn7-pECi1fJPvu0_jk1hn8SRtTkiD1DWVyijXwi51PD-KR3eHnjjszTEWUVFFLjTGLXBcySMVWBDDdfjsee0_H2ugdz4qEDIBRi1woiiZVVSGgG7HCj3df5r68W3r8IJoBIKU0gcJTgUD6QUeV2qeF08OZDzt46ldpYUNPxaooO9xFpzgwYYrWInVUesZBuXuuIl6rYhz8pG5PGk_mox8pO_ehtbKHpGLouLfHQMAsjiSKCnJ2Rg-vpJ-llDsaHdSSD3pxLv4DIucHQLN1wqg-06LVDUXJzgnZs9wf316fF7pYHIxbAC-kW8EZF7yjRdVnbK0kJiUnvH0cODl2WY3lSX5bmocuVGEG5gjOfO4WrkT354mgeODOxktJKXnl6sCtkmirXbgm5EPtWeGTBoVykSMQPArbK2TtdmlVwl90k-Q")
);
}
copied to clipboard

call REST apis for multipart with body

void updateAPI() {
Map<String, String> body = Map();

body["name"] = fullName;
body["email"] = email;
body["license_expiry_date"] = expirationDate;
body["location"] = location;
body["profession"] = selectedProfessionModel.id.toString();
body["specialist"] = specialist;
body["about"] = about;

Map<String, File> mapOfFilesAndKey = Map();
if (isFileExist(profileImage)) {
mapOfFilesAndKey["profile_picture"] = profileImage;//send File
}


ApiRequest(
context: context,
apiCallBackListener: this,
showLoader: true,
httpType: HttpMethods.POST,
url: Url.updateProfile,
apiAction: ApiAction.updateProfile,
body: body,
isMultiPart: true,
mapOfFilesAndKey: mapOfFilesAndKey,
);
}
copied to clipboard
if you want pass header on following format then callCommonFile.getApiHeader(actionToken)
Map<String, String> getApiHeader(accessToken) {
return {
HttpHeaders.acceptHeader: 'application/json',
// HttpHeaders.contentTypeHeader: 'application/json',
HttpHeaders.authorizationHeader: "Bearer " + accessToken,
};
}
copied to clipboard
or else you can pass custom header
Additional information #
You add use additional method


showToastMessage(String message) for display toast messages


hideKeyBoard(BuildContext context) for hide or minimize keyboard


checkInternetConnectivity() for check internet availability or not


Other Package #

flutter_all_social_login
flutter_image_uploading

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.