DEV Community

Cover image for Firebase + Flutter Setup In Simplest Way (Windows)
Om Vastre
Om Vastre

Posted on • Originally published at devom04.hashnode.dev

Firebase + Flutter Setup In Simplest Way (Windows)

There are ways to add firebase to your project but the simplest way is to use FirebaseCLI, I tries with adding domain name to firebase apps then downloading json file and adding it in android app folder and adding library, but there is a catch when er try to add those libraries in that gradle.build files the gradle file structure and the structure shown in firebase add apps step don't match so beginner gets confused so simplest way to add firebase in flutter is to use Firebase CLI. Let's see how to do it:

  1. Download Firebase CLI from here: Download FirebaseCLI
    or direct link to start download : Direct download

  2. Then and run command firebase login and login with required account.

  3. Then need to install 'fireflutter' and add it to path, for that

    • run command : dart pub global activate flutterfire_cli
    • Then you will get to see a warning msg like : "Warning: Pub installs executables into _C:\Users\PC\AppData\Local\Pub\Cache\bin_, which is not on your path. You can fix that by adding that directory to your system's "Path" environment variable. A web search for "configure windows path" will show you how."
    • Add path given in msg in Path variable in Environmental Variables. If you don't add to path you may face 'flutterfire not recognized' error
  4. Then close FirebaseCLI window and open your flutter project.

  5. Now need to add required firebase libraries in flutter project for that open terminal and run command :

    • Firebase Core Lib : flutter pub add firebase_core
    • Firebase Auth lib : flutter pub add firebase_auth
    • Firebase Realtime DB Lib : flutter pub add firebase_database
    • All other libraries are listed here : Fireflutter Official Site
  6. Then run command flutterfire configure and choose project and apps you want to add to firebase project. After that this command will generate a file 'firebase_options.dart' which contains configuration and now go to firebase there you will get to see apps are added to firebase and setup is completed.

Resources : Official Guide, Official Guide Video, FireFlutter

Top comments (0)