Setup the project
Let’s setup the project, but before make sure you have everything ready.
Prerequisites
ShipFlutter uses Flutter and Firebase. Before you start, make sure you have:
-
Setup Firebase CLI (more info)
-
Install Firebase CLI
-
Log into Firebase
-
Install the FlutterFire CLI by running the following command from any directory:
-
Initial setup
To setup the project and workspace follow these steps:
-
Download project
-
Unzip and extract contents to your workspace
-
Open with your IDE
-
Run the
setup.sh
script -
(Optional) Setup git and GitHub
-
Create a new repository on GitHub
-
Run the following command from the root of your project
-
-
Setup Firebase (next section)
Firebase setup
In order to use Firebase in your project you will need to create or select a project, configure the app and the different services you need.
-
Setup Firebase for your app (from within the app folder). This will start the setup process.
-
When prompted, say
yes
to override thefirebase_options.dart
. -
Select or create a Firebase Project
-
Select the platform you want to support.
-
A
firebase_options.dart
file will be created and all targets will be registered in your Firebase project. -
Go back to the root and select the project you just created by running:
-
It will prompt for an alias. Just give it
default
-
Complete the required services setup step below
After these setps, the firebase setup is ready and the app can run but some Firebase service might not work yet. Additionally, each module might require additional configuration to work.
Required services setup
The basic core features of the app require you to set up Firestore, Firebase Authentication, and App Check (for Flutter Web) first.
All other Firebase services are optional and can be setup later if needed.
Firebase Firestore
Enable and setup Firestore in your Firebase project.
-
Create the database from the Firebase console
-
Open a terminal and run the following command from the root of the project:
- Select
Firestore
from the list of available Firebase services - Select your project
- (Optional) Use the existing
firestore.rules
andfirestore.indexes.json
files
- Select
-
(Optional) Deploy the pre-configured rules and indexes:
Firebase Authentication
Enable and setup Firebase Authentication in your Firebase project.
-
Open the associated Firebase Project dashboard.
-
Under Build > Authentication > Sign-in Method tab.
-
Enable Email/Password and Anonymous by adding them as providers
(Optional) Enable social login.
-
Run the app and try to create a new user. It should work :)
Firebase App Check
App Check protects your project from malicious requests. By default it’s unenforced for all services, but for Flutter Web, there is an issue that requires you to setup a debug token otherwise any Firebase request will be denied.
Follow these steps to enable App Check for Flutter Web:
-
Open the App Check - Apps tab in the Firebase Project dashboard.
-
Enable App Check (if not already enabled)
-
Click on the three dots menu in the Web app row.
-
Click on the “Manage debug tokens” button.
-
Click on the “Add debug token” button.
-
Input any name and generate a token (copy the token to your clipboard!).
-
Replace the token in the
app/lib/web/index.html
file:
Running the app
Run the app by running:
You can also select a target or run the app via VSCode or Android Studio (more info).