flutter_rest_http 0.0.2 copy "flutter_rest_http: ^0.0.2" to clipboard
flutter_rest_http: ^0.0.2 copied to clipboard

Easily integrate to json based rest APIs.

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

Usage #

1. Import Package #

import 'package:flutter_rest_http/flutter_rest_http.dart';

2. Initialization #

In your main method in lib/main.dart add the following block

void main(){
    RestHttp.init(
        baseURL: "https://jsonplaceholder.typicode.com/"
    );
}

3. Make GET Request #

void getPosts(){
  RestHttp.get("posts").then((res) {
    //handle response
  }).catchError((err, stack) {
    //handle errors
  });
}

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
  });
}

1
likes
130
pub points
0%
popularity

Publisher

unverified uploader

Easily integrate to json based rest APIs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on flutter_rest_http