In this tutorial, we are going to build Flutter APP to send data to JSONPlaceholder(Fake Online REST API for Testing and Prototyping). This is an example app that can post a text data to a web server and receive the same data as a response if resource successfully created. Having the ability to do HTTP Post Request Flutter app to the remote server is required for most apps.  

Flutter Post Request

1. Add Package

In this example, we are using an HTTP dart package for creating an HTTP post request. It is a composable, Future-based library for making HTTP requests. This package contains high-level functions and classes that make it easy to consume HTTP resources.

Add following dependencies to your package’s pubspec.yaml file.You can find the latest version of the http package on the pub website.

2.Create Post Class

First, we’ll need to create a Post class that contains the data from our network request. It will also include a factory constructor that allows us to create a Post from json.

3. Make a HTTP POST request

In this example, we’ll send a sample post to the JSONPlaceholder REST API using the http.post()method.

The http.post() method returns a Future that contains a Response.The http.Response class contains the same date received from a successful http call.

Complete example