Flutter & Firebase App Tutorial — Part 2 App Structure

Jumei Lin
4 min readOct 23, 2021

--

Create a flutter authenticate app in 10 mins by using firebase as the back-end. This Flutter tutorial is for beginners to build an app step by step with Firebase authenticate feature.

If you haven’t set up your environment, please go to Flutter & Firebase App Tutorial — Part 1 Get Started.

More Tutorials:

Flutter & Firebase App Tutorial by Lumei Digital
Flutter & Firebase App Tutorial by Lumei Digital

Table of Contents

  • Create folder structure
  • Create widgets

These are the folders and files that we are about to create:

The folder structure in a Flutter App — Lumei Digital
The folder structure in a Flutter App — Lumei Digital

Step 1: Create folders to better structure the codes

Create a few folders inside the lib folder so that we can organize codes efficiently.

Create folders in a Flutter App — Lumei Digital
Create folders in a Flutter App — Lumei Digital

Step 1.1 👉 screens folder: all the widgets that make up the different screens are inside this folder.

Step 1.2 Create subfolders for different sections of your app.

➡️ home: a sub-folder of screens folder. All the different widgets that create the home screen will live in this folder.

➡️ authenticate: a sub-folder of screens folder. All the different widgets that create the authenticate screen will live inside this folder.

Step 2: Create widgets

Step 2.1 Create a new file called “authenticate.dart” inside the authenticate folder. It will be the root authenticate widget and shows either the “Sign in” widget or the “Sign Up” widget.

Step 2.1 Create a stateless widget called “Home” inside the home folder. It’s the widget that wraps the list widget

Create Home widget in a Flutter App — Lumei Digital
Create a Home widget in a Flutter App — Lumei Digital

Step 2.2 Create a stateful widget called “Authenticate”. We will use State in the future inside this widget. Do the same for

➡️SignIn

➡️SignUp

Create Authenticate widget in a Flutter App — Lumei Digital
Create Authenticate widget in a Flutter App — Lumei Digital

type in stless and then tab to create a stateless widget

Step 2.3 Create a stateless widget called “Wrapper” to return either Home or Authenticate widget

Step 3: Show Wrapper widget in the main.dart

Remove everything inside the MaterialApp and then the home property will be the Wrapper widget.

Next, we are gonna introduce Firebase Auth into the app.

More Tutorials:

Seeing my followers grow will encourage me to write more articles. If you have any questions or anything to be improved please write a comment in the comments section.

I am a Flutter lover, and I talk about flutter, mobile development, and artificial intelligence.

👉 The source code is updated in Github

--

--

Jumei Lin

Entrepreneur, Writes about artificial intelligence, AWS, and mobile app. @Lumei Digital