quick_request

Last updated:

0 purchases

quick_request Image
quick_request Images
Add to Cart

Description:

quick request

Quick Request #
The quick_request Flutter package allows you to make HTTP requests quickly and easily. Using the http package, you can perform API requests in a simple and effective manner.
Features #

Easy HTTP requests (GET, POST, PUT, PATCH, DELETE)
ResponseModel class for handling responses
Automatic encoding and decoding of JSON data

Usage #
GET Request
Future<ResponseModel> fetchPosts() async {
return await QuickRequest().request(
url: "https://api.example.com/posts",
requestMethod: RequestMethod.GET,
);
}
copied to clipboard
POST Request
Future<ResponseModel> createPost(Map<String, dynamic> data) async {
return await QuickRequest().request(
url: "https://api.example.com/posts",
body: data,
requestMethod: RequestMethod.POST,
);
}
copied to clipboard
PUT Request
Future<ResponseModel> updatePost(int id, Map<String, dynamic> data) async {
return await QuickRequest().request(
url: "https://api.example.com/posts/$id",
body: data,
requestMethod: RequestMethod.PUT,
);
}
copied to clipboard
DELETE Request
Future<ResponseModel> deletePost(int id) async {
return await QuickRequest().request(
url: "https://api.example.com/posts/$id",
requestMethod: RequestMethod.DELETE,
);
}

copied to clipboard
PATCH Request
Future<ResponseModel> patchPost(int id, Map<String, dynamic> data) async {
return await QuickRequest().request(
url: "https://api.example.com/posts/$id",
body: data,
requestMethod: RequestMethod.PATCH,
);
}
copied to clipboard
Authorized Request
Future<ResponseModel> fetchSecurePosts() async {
String? token = LocalManager().getStringValue(LocalManagerKeys.accessToken);
return await QuickRequest().request(
url: "https://api.example.com/secure-posts",
bearerToken: token,
requestMethod: RequestMethod.GET,
);
}
copied to clipboard
GET Request with Query Parameters
Future<ResponseModel> fetchPostsWithQueryParameters() async {
return await QuickRequest().request(
url: "https://api.example.com/posts",
queryParameters: {
"userId": "1",
},
requestMethod: RequestMethod.GET,
);
}

copied to clipboard
Example PATCH Request
Future<ResponseModel> patchPostExample(int postId, String newTitle) async {
return await QuickRequest().request(
url: "https://api.example.com/posts/$postId",
body: {"title": newTitle},
requestMethod: RequestMethod.PATCH,
);
}

copied to clipboard
with alert_craft usage
Future<void> _fetchData() async {
final apiRequest = QuickRequest();
try {
final response = await apiRequest.request(
url: 'https://api.example.com/posts/1',
requestMethod: RequestMethod.GET,
);
if (!response.error) {
setState(() {

ShowAlert().showToastMessage(type: 1, title: "successful", description: "response.data");
});
} else {
setState(() {
ShowAlert().showAlertDialog(type: 1, title: "error", description: "response.message");
});
}
} catch (e) {
setState(() {
_responseMessage = 'Exception: $e';
});
}
}

copied to clipboard
Installation #
To add the quick_request package to your project, include the following line in your pubspec.yaml file:
dependencies:
quick_request: ^0.0.1
copied to clipboard

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.