Flutter : Integrating Google Sign-In

Updated 27 December 2023

Save

Social Authentication like- Facebook, Google, Twitter, and Linkedin in the mobile apps is the most commonly used feature now a days . We can sign up and sign in to the app using the details of our social sites/app.

In this article, we are going to explore how we can integrate Google sign-in flutter.

You may also check our  flutter app development services

So, let’s start.

First, we need to create an account and set up our project on Firebase.
We are assuming that you have set up your project on Firebase and are ready to move further in fluter code.

Android Integration:

Register your Android application in Firebase from the link.

Enable the OAuth APIs that you want, using the Google Cloud Platform API manager.

Note: Please fill in all required fields in the console for the OAuth consent screen. Otherwise, you might get APIException errors.

Download google-services.json file and add to the module (app-level) root directory of your app inside the Android folder.

IOS Integration:

Register your iOS application in Firebase from the link.

Download GoogleService-Info.plist file, and add in Runner target.

 Add the below code in [your_project_name]/ios/Runner/Info.plist file.

Dependencies:

Add the below dependencies in the Pubspec file of your project

Import

Example

Let’s take an example.
In this example, we have taken two screens and files.
Note: In this example, we are only handling the google login button event.

  1. Main.dart: In this file, we added a Google button. On the button click event, Google authentication will start.
  2. HomePage.dart: After successful authentication, we will be redirected to the Home screen.
    Account details will be displayed on this screen.

main.dart

HomePage.dart

Now, run the code and check the result.

Result

Android App Result :

IOS App Result :

Conclusion :

In this blog, we have checked that how we can add Google authentication in the Flutter Apps.

For more information about social authentication please follow the Link.

Thanks For Reading

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home