VOOZH about

URL: https://www.geeksforgeeks.org/flutter/building-a-movie-database-app-in-flutter/

⇱ Building a Movie Database App in Flutter - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Building a Movie Database App in Flutter

Last Updated : 23 Jul, 2025

In this tutorial, we'll create a Flutter app that fetches movie data from an API, displays details such as ratings and reviews, and allows users to save their favorite movies locally using SQLite. This Application will demonstrate API integration, state management, and local data persistence.

Application Features

  1. Search for movies by name or genre.
  2. View detailed movie information (cast, plot, rating, etc.).
  3. Save and retrieve favorite movies locally.
👁 Building-a-movie-database-app-in-flutter


What API is used in the Application

For this app, we’ll use the OMDb API to fetch movie data. OMDb is a free API that provides movie information like titles, posters, IMDb ratings, etc. You can get an API key from OMDb after signing up.

Setting Up the Project

Creating the Flutter Project

Create a new Flutter application using the command Prompt. To create a new app, write the below command and run it.

flutter create app_name

To know more about it refer this article: Creating a Simple Application in Flutter

Installing Dependencies

For this project, you’ll need these dependencies:

  1. http: To make network requests to the OMDb API.
  2. sqflite and path_provider : To save and manage favorite movies in a local SQLite database.

Add these dependencies in your pubspec.yaml file:


Run the following command to install the dependencies:

flutter pub get

Folder Structure

Create the following folder structure for better organization of your files:

This structure keeps database logic, models, services, and UI separated, making the code modular and easy to maintain.

👁 Screenshot-2024-10-13-203439

Build the Application

The Application is divided into the following packages:

  • Models: Contains Objects that encapsulate the data and behavior of the application domain.
  • UI elements: These Contain Code that defines the UI of the Application.
  • API Services: It contains the code able to maintain the API Services
  • Database Helper: This part helps us to manage data in our local storage(SQLite).

Step 1 : Models

Let's start by creating a model for our movie data in movie.dart.

movie.dart


Now create another Model movie_details.dart; .this will store the movie details.

movie_details.dart


Step 2 : API Service

Create the movie_service.dart file to handle the API calls using the http package.

movie_service.dart


Step 3. Database Helper

Next, we’ll create the db_helper.dart file to manage saving favorites using SQLite to our local storage.

db_helper.dart


Step 4. UI Components

Our Application contains three main UI Components Screens, as mentioned below:

  • Home Screen
  • Movie Details Screen
  • Favorites Screen

Now let us Observe all them.

-

The home_screen.dart is where users can search for movies:

home_screen.dart

Screenshot of Home Page:

👁 HomePage

-

The movie_details_screen.dart is where users can see the movie details :

movie_details_screen.dart

Screenshot of the Movie Details Screen:

👁 movie_details

-

The favorites_screen.dart displays the movies added to favorites and stored in the local database :

favorites_screen.dart

Screenshot of the Favorites Screen:

👁 favorites

Main Application File Code

After successfully creating Models, Service, and Helper files, we can finally utilize them to create a fully functional Application.

Finally, let's Call Our HomeScreen from the main.dart file.

main.dart

Complete code for the Application Here : Movie_Database_Application

Output :


Comment

Explore