Task 13:
Topic: working with Firebase database
Objective: This lab task is to exercise on firebase.
To use firebase database for our mobile application we must follow the following steps.
Before we are going to work with large data first, we must connect flutter with firebase with out
any issue. To data that please create a default mobile app (counter app) with the name of
check_firebase.
Than try to access firebase console (https://console.firebase.google.com/)
COMPILED BY TADESSE SHEFERA 102
Next click on Create a Firebase Project
Next Enter your project name. (for us use checkfirebase)
After you enter the project name click continue.
Finally create project (this may take minutes)
COMPILED BY TADESSE SHEFERA 103
Than click continue
Than select the app that you went to develop (for now connect with android)
Click the android icon and than you get the following.
COMPILED BY TADESSE SHEFERA 104
For Android package name add application id from android/app/build.gradle file
Then Register app
For the second step download the google-service and add into your module (app-level)
COMPILED BY TADESSE SHEFERA 105
You must add like this
Then click Next
Then add plugin in build.gradel into app-level and project level
COMPILED BY TADESSE SHEFERA 106
Fist for project level copy id 'com.google.gms.google-services' version '4.4.2' apply false into root level
build.gredle. but for newest flutter version add this plugin in settings.gradle
It is recommended to use the latest version of Kotlin. Currently the latest version of kotlin is 2.1.20.
(https://kotlinlang.org/docs/releases.html). Than update the 3rd plugin from the above based on this
Then save and leave this file
After that add google-services plugin in app-level
Now we need to add firebase_core plugin and for this add firebase_core dependency from pub.dev
use the following shortcut
Ctrl+Shift than write add dependency
Next write firebase_core
COMPILED BY TADESSE SHEFERA 107
Then automatically the dependency is added from pub.dev
next on main.dart file make the void main () method asynchronous.
the next step is initializing firebase and to do this add the following two lines of code in main() method
finally run your application
warnning: make sure you are using our android phone to run this!
If you went to run by web (not recommended) you can read the shared pdf file firebase_for_web.pdf
Happy codding !!
COMPILED BY TADESSE SHEFERA 108