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

in #utopian-io6 years ago (edited)

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

Sort:  

Excellent work @tensor - Approved.

I thoroughly enjoy watching your tutorials. Excellent text accompaniment as well as Github supplementary materials. Well organized and presented. Top drawer.

You mentioned you were going to link to the "Materials Design Spec" in the text, I could not find it. That would be a nice addition for learners, but no worries.

Keep up the excellent work. We are lucky to have your talents on Utopian.

Cheers,
Buckydurddle

You can contact us on Discord.
[utopian-moderator]

Oh yes, I linked it in the YouTube description but forgot to link it here. Thank you for reviewing my contribution and giving me feedback.

Hey @tensor I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64269.87
ETH 3393.79
USDT 1.00
SBD 2.48