![]() |
VOOZH | about |
In app development, the ability to fetch data from external sources, such as REST APIs, is a fundamental requirement. In Flutter, whether you need to send some data to the RESTful API, access a database, or then Send content from the Flutter App, Flutter provides you with the tools and packages(HTTP) to do this kind of API calls easily. Here we will explore how to interact with external data sources, Send JSON data(Key-Value pairs), and integrate it into your Flutter application.
To build this app, you need the following items installed on your machine:
This is a API link of HTTP POST Request
POST - https://jsonplaceholder.typicode.com/posts
To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter.
In the pubspec.yaml file we have to add the below dependency for the http package which provide varrious API call methods.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
http: ^1.1.0
First of all import material.dart file.
import 'package:flutter/material.dart';
Here the execution of our app starts.
In this class we are going to implement the MaterialApp , here we are also set the Theme of our App.
In this class we are going to make HTTP POST request to the API endpoint and Display the result that would received from the API (Sucess Status Code for this API call is 201).
Here is the full Code of main.dart file