Introduction

In this article, I will be showing how to set up and implement Google Sign In using Firebase Authentication.

There are a number of articles out there showing how to implement sign-in or login in Flutter, but I am still writing this article because there has been a lot of changes in Flutter ( after the release of Flutter 1.7 ) as well as in the Firebase Google Sign In.

So, I recommend that you have a look at this article at least till the end of Google Sign In setup if you want to start building a new app using Firebase.

So, let’s get started.

Flutter 1.7

With the introduction of Flutter 1.7, the most frustrating thing fixing AndriodX incompatibilities has been taken care of. Now, you can just create a new project using the --androidx flag to ensure the generated project targets the new support library. I will be using this later in the article while creating the project.

Few other important things that have been included in Flutter 1.7, is the support for Android App Bundle and 64-bit Android App support, which is very helpful if you want to publish your app in Play Store. Till now, we had to change the Flutter branch from stable to beta in order to generate Android App Bundle, but now it is available in the stable branch.

You can check out the article “Announcing Flutter 1.7” by Tim Sneath if you want to know about all the new features included in Flutter 1.7.

Google Sign In

There are a few new steps you have to do in order to use Google Sign In in your app. Without completing all these steps, if you try to use Google Sign In, your app will just crash. I will show you how to set up Google Sign In using Firebase from scratch.

App Screenshots

Our final app will look like this:

Implementation

Before diving into the real coding part, let’s see what are the plugins and assets required in this project.

Plugins

The plugins needed for this project are:

firebase_auth (for using Firebase Authentication) google_sign_in (for the implementation of Google Sign In)

Assets

Only one image is needed for this project which we will be requiring while designing the Google Sign In button in our app.

You can get the image from here:

Creating the project

Let’s create a new flutter project with AndroidX compatibility.

Open Terminal or use the terminal in your code editor. Navigate to the folder where you want to create the project and use the following command:

flutter create --androidx sign_in_flutter

This will add AndroidX compatibility to the project automatically.

But for using the --androidx flag you need to be on the latest version of Flutter on the stable branch.

To check which branch you are currently on, use the command:

flutter channel

The channel marked with an asterisk (*) is your current branch.

2. To change the branch to stable, use the following command:

flutter channel stable

3. Then upgrade, using the command:

flutter upgrade

Importing packages