Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 2)

What Will I Learn?

  • You will learn how to implement and use an SQLite database with SQflite
  • You will learn how to properly structure and refactor a flutter applicaiton
  • You will learn how to implement the Material Design list guideline specifications
  • You will learn how to attach internal state to specific widgets
  • You will learn how to use an Expansion Tile Widget
  • You will learn how to use Factory keyword in Dart

Requirements

Difficulty

  • Intermediate

Description

In the second part of this tutorial, we build on the application that was built in the first part. We add in a data layer, refactor the user interface and wire up the database to the other pieces of the application. We also refactor the our code by splitting the different elements into multiple folders.

We take the movie view widget and move it into its own file inside of a folder called views. This helps us reorganize the code in a way that is readable. We then refactor this code change the widget type into an expansion tile widget. The expansion tile widget extends the list tile widget with the ability to expand and contract the widget to reveal another widget. In this application, we use this functionality so that we can display the overview text for each of our movies.

We move the star favorite button to the far left of the expansion tile. This helps make the application feel more professional and keeps it inline with the guidelines for the material design list specification. In this way, we can have our primary action on the left and the secondary action on the right.

We then set up our database by creating a new folder and file called database. This file then contains the movie database class. In this class, we have an internal getter method that lets us abstract over top of our database. Then we also add in a factory method which allows the class to dispatch instances of our database as needed. This class also allows us to initialize the SQLite database in a way that is safe. The class also contains various methods which can affect the data of our database.

Finally, we wire up the database to our movie cards so that when a user clicks on the star button, the movie object gets placed into the database. In this way, the user can save the movies they want to watch in the database for use in other parts of the application.

Material Design Guidelines can be found here

The source code for this project can be found here

Video Tutorial

Tutorial Videos

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
3 Comments