I started by googling firebase flutter login example. The top link was a FlutterFire page:Using Firebase Authentication. When I clicked on it, the NOTICE said that this page was superseded. It gave links to the page with the latest information.
Get Started with Firebase Authentication on Flutter
I follow “the page with the latest information”.
Firebase Account
I registered to Firebase using my Google persona, h.gurgenci@gmail.com. I was in immediately and no password had to be invented. This first worried me but then I realised that I logged in as the Google account holder and others would have to know my Google password to access my Firebase page.
Project
I then added a project. I called it pascall-2022. Firebase projects are containers for one’s apps and many apps can be contained in a single project. At least, this is my understanding now. Here is how my firebase console looks with one project:
The app
I will use the flutter default app (counter app). This is the app that is created automatically when you create a new project.
Firebase CLI
I am using Mac. I opened a terminal on VS Code. It automatically opened a bash terminal. I entered the following command:
$ curl -sL https://firebase.tools | bash
It asked for a password. Foolishly, I thought it was asking for my Google password. I entered it but it did not work. I panicked first and then realised that it was asking me for the computer password because it made changes to my computer. I provided that and Firebase CLI was installed in about 30 seconds:
I then entered
$ firebase login
from the same terminal window. I had to authenticate my Google identity and then I was in. I was able to list my projects bu entering
$ firebase projects:list
and saw:
I then tried
$ firebase init
I picked all the options offered and picked pascall-2022 as the existing project to associate with this initialisation. I opted for southeast1 for the location of my real-time database instance and accepted database.rules.json as the file to which Security rules are written.
It was all going well until the FireStore Setup. Then it bombed out:
I then used the link to start a Firestore plan. I opted for the free plan, spark:
I tried again but failed again. I realised that I have to choose between Realtime Database and Cloud Firestore Database. I tried firebase init again and this time turned off Cloud Firestore Datatabse. This time it went further. I made the following choices:
Cloud functions to be written in javascriopt instead of TypeScript (these are the only two options)
Said yes to the ELint question
Watched it installing npm
Then it bombed out again, because Cloud resource location was not set.
On Firebase comnsole for this project (pascall), I picked East Asia as the storage location:
The last menu was on the emulators. I picked all and downloaded and installed all.
Add Firebase Authentication to your app
After installing and intialising all Firebase SDKs in the preceding section, we now run the following command to install the plugin:
flutter pub add firebase_auth
this executed without a problem. I now run the app
flutter run
This also runs with no problem. I have now installed FireBase authentication tools but I am not using them yet. This will be the topic of the next page.