Arpit Sharma
2 min readJan 9, 2021


Flutter Provider along with Http request

YouTube and Medium are flooded with tutorials for Provider package and Http APIs package but there are not many for using provider along with http.

No problem, let me help you with this…..

Provider :


Gain knowledge about Provider and Http with pub extremely helpful documentation for better understanding about how these packages work.


Create a new Flutter project and name it anything you like
and go to pubspec.yaml, add packages provider and http

provider: ^4.3.2+3
http: ^0.12.2

Lets have a look on the main.dart file

Here only ChangeNotifierProvider initialised for its availability through entire application.

For this project I have used JsonPlaceholder API :

For using Provider or http, flutter need model to be created for a particular API data,

If you are thinking it will take lots of time for creating a model for every API you use, than will help you to convert JSON format to dart.

Now let’s create Provider class:

Now homeScreen.dart, where we will represent API call data in a list view using Consumer and Provider.of<ProviderClass>(context, listen: false) for API calls.

Consumer Class :

Now if you remember we have created a dummy variable to check if provider class is working perfectly or not, there is a navigation button with redirects to another page where the count can be increased using onPressed : Provider.of<ProviderClass>(context, listen: false).count += 1;

I hope this Helped you……
Github Repository :



Arpit Sharma

R&D Engineer 2 Broadcom (VMware) | SIH'20 Winner #1 | Former Research Intern at Mitacs ( École de technologie supérieure )