Last updated:
0 purchases
flutter rest http
About Package #
Simple package to integrate to JSON based rest API
Getting started #
Run the following command to install the package in your project
flutter pub add flutter_rest_http
copied to clipboard
Usage #
1. Import Package #
import 'package:flutter_rest_http/flutter_rest_http.dart';
copied to clipboard
2. Initialization #
In your main method in lib/main.dart add the following block
void main(){
RestHttp.init(
baseURL: "https://jsonplaceholder.typicode.com/"
);
}
copied to clipboard
3. Make GET Request #
void getPosts(){
RestHttp.get("posts").then((res) {
//handle response
}).catchError((err, stack) {
//handle errors
});
}
copied to clipboard
4. Make POST Request #
void createPost(){
RestHttp.post("posts", params: {
"title": "New post",
"body": "Post description body"
}).then((res) {
//handle response
}).catchError((err, stack) {
//handle errors
});
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.