If you are already in love with Flutter, you must have created many apps as of now. Some of them are maybe small single screen ones and others can be a full-fledged app. I created many too, at first it all seems easy as they were small apps but once I stepped into creating some bigger apps which are based on doing many network calls I started facing various errors and my app starts misbehaving. This all was happening because I was not handling my API calls properly.

In this blog, We will learn how to overcome all these problems by creating a sample movies app which shows a list of popular movies using TMDB API.

Some Prerequisites

As we are going to implement this app using BLOC pattern you should know the basics of Streams and StreamControllers. Some basic knowledge of HTTP response codes and repository pattern will also be going to help you understand this more easily.

The basic architecture of our Application is going to be like this.

Basic Architecture of our Application

Steps we are going to follow in this article :

Creating an API base helper class. Custom app exceptions. MovieResponse model classes. A generic API response class. A repository class to fetch data from APIs. A bloc class for consuming UI events and sending streams. A UI to display all the data.

A deep breath here, just before we dive into absolute bliss.