All Projects → bizz84 → Movie_app_state_management_flutter

bizz84 / Movie_app_state_management_flutter

Licence: mit
Flutter State Management: Movie App with Provider, Riverpod, flutter_bloc

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Movie app state management flutter

Behavior Tree
🌲 Manage React state with Behavior Trees
Stars: ✭ 85 (-24.11%)
Mutual labels:  state-management
Momentum
MVC pattern for flutter. Works as state management, dependency injection and service locator.
Stars: ✭ 99 (-11.61%)
Mutual labels:  state-management
Visly State
React state for real-time apps
Stars: ✭ 106 (-5.36%)
Mutual labels:  state-management
Vuex Pathify
Vue / Vuex plugin providing a unified path syntax to Vuex stores
Stars: ✭ 1,281 (+1043.75%)
Mutual labels:  state-management
Redux Reset
Give redux the ability to reset the state
Stars: ✭ 95 (-15.18%)
Mutual labels:  state-management
Juicr.js
A simple (and tiny <1kb) redux inspired reducer for handling state changes.
Stars: ✭ 102 (-8.93%)
Mutual labels:  state-management
Compare React State Management
React createContext vs Apollo vs MobX vs Redux in a simple todo app.
Stars: ✭ 81 (-27.68%)
Mutual labels:  state-management
Sinai
Type safe state management inspired by Vuex
Stars: ✭ 111 (-0.89%)
Mutual labels:  state-management
Use Substate
🍙 Lightweight (<600B minified + gzipped) React Hook to subscribe to a subset of your single app state.
Stars: ✭ 97 (-13.39%)
Mutual labels:  state-management
Faste
Component based 📦 Finite State Machine Manager 🤖
Stars: ✭ 105 (-6.25%)
Mutual labels:  state-management
Stapp
Modular state and side-effects management for microfrontends
Stars: ✭ 88 (-21.43%)
Mutual labels:  state-management
Sigi
Well designed effect management framework for complex frontend app
Stars: ✭ 95 (-15.18%)
Mutual labels:  state-management
River pod
A simple way to access state while robust and testable.
Stars: ✭ 1,366 (+1119.64%)
Mutual labels:  state-management
Freezer
A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
Stars: ✭ 1,268 (+1032.14%)
Mutual labels:  state-management
Nucleo
🏋️‍♀️ Nucleo is a strongly typed and predictable state container library for JavaScript ecosystem written in TypeScript
Stars: ✭ 109 (-2.68%)
Mutual labels:  state-management
Iflow
Concise & powerful state management framework for Javascript.
Stars: ✭ 81 (-27.68%)
Mutual labels:  state-management
Homebase React
The React state management library for write-heavy applications
Stars: ✭ 101 (-9.82%)
Mutual labels:  state-management
Reworm
🍫 the simplest way to manage state
Stars: ✭ 1,467 (+1209.82%)
Mutual labels:  state-management
Datx
DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.
Stars: ✭ 111 (-0.89%)
Mutual labels:  state-management
Store
Aurelia single state store based on RxJS
Stars: ✭ 103 (-8.04%)
Mutual labels:  state-management

Flutter State Management: Movie App with Provider, Riverpod, flutter_bloc

This reference project shows how to implement a (Netflix-inspired) movie app with different state management techniques in Flutter:

Movie app preview

The project uses the TMDB API to fetch a list of movies, and includes features such as pagination and local storage.

Running the project

Before running, see instructions on how to get a TMDB API key.

Also, make sure to run on Flutter beta channel.

App Overview

The application is composed by three primary screens: Now Playing, Favourites and Profiles.

On first launch, the app asks the user to create a profile.

The Now Playing page loads a list of current movies from the TMDB API. Results are paginated and scrolling to the bottom causes the next page to be loaded.

Each movie shows as a poster using the image URL retrieved from the API. You can tap on the ❤️ icon to add a movie as a favourite (for the selected profile), and this preference is persisted to local disk.

Open the Favourites page to see the list of favourites for the currently selected profile.

Use the Profiles page to create additional profiles and update the currently selected profile (this is inspired by the Netflix UI).

Features

  • "Now Playing" movies (with pagination)
  • Save favourites to watch list
  • Multiple profiles (like Netflix)
  • Local data persistence (movies, favourites, profiles) with Sembast

Combining these features together makes for an interesting case study about state management in Flutter.

App Structure

This app was made to compare and contrast multiple state management approaches. A highly composable architecture has been designed to enable this.

The project folders are structured like this:

/apps
  /flutter_bloc
  /riverpod
  /provider
  ... and more
/packages
  /core
    /lib
      /api
      /models
        /app_models
        /app_state
        /tmdb
      /persistence
      /ui

Each folder inside apps is a Flutter project that implements the same app with a specific state management package.

All common functionality lives in packages/core. This includes a TMDB API wrapper, along with model classes with supporting serialization code where needed.

The persistence folder contains a DataStore abstract class that is used by all apps, along with a concrete SembastDataStore class to read and write data to local storage (using Sembast as a NoSQL database).

The ui folder contains all the custom widgets that are shared by all apps. These widgets do not hold any business logic and are designed to show the app UI and expose callbacks for the application code to plug into (much like the built-in Flutter widgets).

All the logic lives inside the apps themselves. All apps have exactly the same folders:

lib
  /app
    /app_startup
    /create_profile
    /favourites
    /now_playing
    /profile_selection

The business logic and screen flows are identical for each app, but the semantics change depending on which state management package is used. This makes it easy to compare and constrast different solutions.

Supported state management solutions

The current state management solutions are currently supported:

I plan to add more in the future (PRs welcome!).

Future Roadmap

  • Convert project to null safety (once the Freezed package supports this).
  • Add more screens
  • Polish the UI
  • Replace http with dio to support request cancellation

Feel free to open issues if you'd like certain features to be implemented (though keep your expectations low, I'm doing this for free after all 😉).

Other packages in use

The "core" package of the app uses the following packages:

Getting a TMDB API key

This project uses the TMDB API to get the latest movies data.

Before running the app you need to sign up on the TMDB website, then obtain an API key on the settings API page.

Once you have this, create an api_keys.dart file inside packages/core/lib/api, and add your key:

// api_keys.dart
String tmdbApiKey = "your-api-key";

Congratulations, you're good to go. 😎

Note: Loading images from insecure HTTP endpoints

The data returned by the TMBD API points to image URLs using http rather than https. In order for images to load correctly, the following changes have been made:

Android

Created a file at android/app/src/main/res/xml/network_security_config.xml with these contents:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

Added this to the application tag in the AndroidManifest.xml:

android:networkSecurityConfig="@xml/network_security_config"

iOS

Add the following to ios/Runner/info.pList:

  <key>NSAppTransportSecurity</key>
  <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
  </dict>

More information here:

Credits

This project was inspired by flutter_architecture_samples by the Flutter community.

LICENSE: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].