Flutter + BloC + Back4App = Basic Chat App

https://www.youtube.com/watch?v=qUvI0D1rmwc

Requirements:

  • This tutorial requires you need to know BloC knowledge. If not, please read this document first. [EDITED: new bloc version has been supported in this tutorial]

Direction:

  1. Setup a new app on Back4App with Live Query enabled.
  2. Create UI for 3 pages: login, signup, and home page.
  3. Create Repository.
  4. Create Business Logic (BloC) for each page.

Setup a new app on Back4App:

  • Back4App is a flexible and scalable platform based on the Parse platform.
  • Create New App: Back4App-Demo
  • Copy application configs to main.dart
App Settings on Back4App
Enable Live Query in Server Settings
main.dart

Create UI

  1. Login page:
login page
  • The full source code of the login page looks like this:
login.dart
signup page
  • The full source code of signup page:
signup.dart
home page
  • The full source code of home page:
home.dart

Create Repository:

  • User Repository: handle login/signup logic. This is the main class that interacts with the User class on Back4App.
user_repos.dart
  • Message Repository: the responsibility of this class is to manage the sending message process.
message_repos.dart

Business Logic (BloC)

  1. Auth BloC: Our AuthCubit is responsible for receiving events and converting them into AuthStates. It will have a dependency on UserRepository so that it can retrieve ParseUser when the app started.
  • AuthStates:
auth_states.dart
  • AuthCubit:
auth_bloc.dart
  • LoginStates:
login_states.dart
  • LoginCubit:
login_bloc.dart
  • SignupStates:
signup_states.dart
  • SignupCubit:
signup_bloc.dart
  • HomeStates:
home_states.dart
  • HomeCubit:
home_bloc.dart

--

--

--

I’m a peaceful person who wants to make friend with people around the world.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Web Performance for the People

How I solve coding challenges using The “Start small grow big” and “Think twice,code once” method

Mobile Web vs. Mobile App

Column or expression in SELECT list not valid exception

How to get into Game Development? Practical advices

A Guide On Laravel Relationships

An Important Month Resulting In Greatness

Automatically render Microsoft Teams Call Flow Diagrams

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Trong Dinh Thai Hoang

Trong Dinh Thai Hoang

I’m a peaceful person who wants to make friend with people around the world.

More from Medium

How to add launcher/app icons to flutter

Easy way to implement User Session-Timeout feature in Flutter

Everything you need to know about Flutter 2.0

Flutter Authentication with Firebase.