google_sign_in 2.1.0

  • Example
  • Installing
  • Versions
  • 95


pub package

A Flutter plugin for Google Sign In.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

Android integration

To access Google Sign-In, you'll need to make sure to register your application.

You don't need to include the google-services.json file in your app unless you are using Google services that require it. You do need to enable the OAuth APIs that you want, using the Google Cloud Platform API manager. For example, if you want to mimic the behavior of the Google Sign-In sample app, you'll need to enable the Google People API.

iOS integration

  1. First register your application.
  2. Open Xcode. You'll have to paste this into Xcode to properly register GoogleServices-Info.plist.
  3. Select GoogleServices-Info.plist from the file manager and drag that file into the Runner directory, [my_project]/ios/Runner/GoogleServices-Info.plist.
  4. A dialog will show up and ask you to select the targets, select the Runner target.
  5. Then add the CFBundleURLTypes attributes below into the [my_project]/ios/Runner/Info.plist file.
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
			<!-- TODO Replace this value: -->
			<!-- Copied from GoogleServices-Info.plist key REVERSE_CLIENT_ID -->
<!-- End of the Google Sign-in Section -->


Import the package

To use this plugin, follow the plugin installation instructions.

Use the plugin

Add the following import to your Dart code:

import 'package:google_sign_in/google_sign_in.dart';

Initialize GoogleSignIn with the scopes you want:

GoogleSignIn _googleSignIn = new GoogleSignIn(
  scopes: [

You can now use the GoogleSignIn class to authenticate in your Dart code, e.g.

Future<Null> _handleSignIn() async {
  try {
    await _googleSignIn.signIn();
  } catch (error) {


Find the example wiring in the Google sign-in example application.

API details

See the google_sign_in.dart for more API details.

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!


  • Enabled use in Swift projects.


  • Simplified and upgraded Android project template to Android SDK 27.
  • Updated package description.


  • Breaking change. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version of the plugin. Instructions can be found here.
  • Relaxed GMS dependency to [11.4.0,12.0[


  • Add FLT prefix to iOS types


  • Support setting foregroundColor in the avatar.


  • Change GMS dependency to 11.+


  • Make GoogleUserCircleAvatar fade profile image over the top of placeholder
  • Bump to released version


  • Updated GMS to always use latest patch version for 11.0.x builds


  • Add a new GoogleIdentity interface, implemented by GoogleSignInAccount.
  • Move GoogleUserCircleAvatar to "widgets" library (exported by base library for backwards compatibility) and make it take an instance of GoogleIdentity, thus allowing it to be used by other packages that provide implementations of GoogleIdentity.


  • Plugin can (once again) be used in apps that extend FlutterActivity
  • signInSilently is guaranteed to never throw
  • A failed sign-in (caused by a failing init step) will no longer block subsequent sign-in attempts


  • Updated dependencies
  • Breaking Change: You need to add a maven section with the "" endpoint to the repository section of your android/build.gradle. For example:
allprojects {
    repositories {
        maven {                              // NEW
            url ""   // NEW
        }                                    // NEW


  • Update to use GoogleSignIn CocoaPod


  • Fix crash on iOS when signing in caused by nil uiDelegate


  • Require the use of support-v4 library on Android. This is an API change in that plugin users will need their activity class to be an instance of Flutter framework provides such an activity out of the box:
  • Ignore "Broken pipe" errors affecting iOS simulator
  • Update to non-deprecated application:openURL:options: on iOS


  • Prevent race conditions when GoogleSignIn methods are called concurrently (#94)


  • Fix signOut and disconnect (they were silently ignored)
  • Fix test (#10050)


  • Don't try to sign in again if user is already signed in


  • Initial Release


// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:convert' show JSON;

import "package:http/http.dart" as http;
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';

GoogleSignIn _googleSignIn = new GoogleSignIn(
  scopes: <String>[

void main() {
    new MaterialApp(
      title: 'Google Sign In',
      home: new SignInDemo(),

class SignInDemo extends StatefulWidget {
  State createState() => new SignInDemoState();

class SignInDemoState extends State<SignInDemo> {
  GoogleSignInAccount _currentUser;
  String _contactText;

  void initState() {
    _googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {
      setState(() {
        _currentUser = account;
      if (_currentUser != null) {

  Future<Null> _handleGetContact() async {
    setState(() {
      _contactText = "Loading contact info...";
    final http.Response response = await http.get(
      headers: await _currentUser.authHeaders,
    if (response.statusCode != 200) {
      setState(() {
        _contactText = "People API gave a ${response.statusCode} "
            "response. Check logs for details.";
      print('People API ${response.statusCode} response: ${response.body}');
    final Map<String, dynamic> data = JSON.decode(response.body);
    final String namedContact = _pickFirstNamedContact(data);
    setState(() {
      if (namedContact != null) {
        _contactText = "I see you know $namedContact!";
      } else {
        _contactText = "No contacts to display.";

  String _pickFirstNamedContact(Map<String, dynamic> data) {
    final List<Map<String, dynamic>> connections = data['connections'];
    final Map<String, dynamic> contact = connections?.firstWhere(
      (Map<String, dynamic> contact) => contact['names'] != null,
      orElse: () => null,
    if (contact != null) {
      final Map<String, dynamic> name = contact['names'].firstWhere(
        (Map<String, dynamic> name) => name['displayName'] != null,
        orElse: () => null,
      if (name != null) {
        return name['displayName'];
    return null;

  Future<Null> _handleSignIn() async {
    try {
      await _googleSignIn.signIn();
    } catch (error) {

  Future<Null> _handleSignOut() async {

  Widget _buildBody() {
    if (_currentUser != null) {
      return new Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          new ListTile(
            leading: new GoogleUserCircleAvatar(
              identity: _currentUser,
            title: new Text(_currentUser.displayName),
            subtitle: new Text(,
          const Text("Signed in successfully."),
          new Text(_contactText),
          new RaisedButton(
            child: const Text('SIGN OUT'),
            onPressed: _handleSignOut,
          new RaisedButton(
            child: const Text('REFRESH'),
            onPressed: _handleGetContact,
    } else {
      return new Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          const Text("You are not currently signed in."),
          new RaisedButton(
            child: const Text('SIGN IN'),
            onPressed: _handleSignIn,

  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: const Text('Google Sign In'),
        body: new ConstrainedBox(
          constraints: const BoxConstraints.expand(),
          child: _buildBody(),

1. Depend on it

Add this to your package's pubspec.yaml file:

  google_sign_in: "^2.1.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:google_sign_in/google_sign_in.dart';
Version Uploaded Documentation Archive
2.1.0 Feb 15, 2018 Go to the documentation of google_sign_in 2.1.0 Download google_sign_in 2.1.0 archive
2.0.1 Jan 12, 2018 Go to the documentation of google_sign_in 2.0.1 Download google_sign_in 2.0.1 archive
2.0.0 Dec 20, 2017 Go to the documentation of google_sign_in 2.0.0 Download google_sign_in 2.0.0 archive
1.0.3 Jan 20, 2018 Go to the documentation of google_sign_in 1.0.3 Download google_sign_in 1.0.3 archive
1.0.2 Jan 20, 2018 Go to the documentation of google_sign_in 1.0.2 Download google_sign_in 1.0.2 archive
1.0.1 Oct 17, 2017 Go to the documentation of google_sign_in 1.0.1 Download google_sign_in 1.0.1 archive
0.3.1 Jul 7, 2017 Go to the documentation of google_sign_in 0.3.1 Download google_sign_in 0.3.1 archive
0.2.1 Jun 22, 2017 Go to the documentation of google_sign_in 0.2.1 Download google_sign_in 0.2.1 archive
0.2.0 Jun 20, 2017 Go to the documentation of google_sign_in 0.2.0 Download google_sign_in 0.2.0 archive
0.0.6 Jun 14, 2017 Go to the documentation of google_sign_in 0.0.6 Download google_sign_in 0.0.6 archive

All 15 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 15, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1
  • Flutter: 0.0.22


Describes how popular the package is relative to other packages. [more]
99 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
76 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: unsure

Error(s) prevent platform classification.


  • Fix dependencies in pubspec.yaml.

    Running flutter packages pub upgrade failed with the following output:

    ERR: Invalid argument(s): Minimum version ("2.0.0-dev.23.0") must be less than maximum ("2.0.0-dev.16.0").
    ERR: package:pub_semver/src/version_range.dart 59         new VersionRange
     package:pub/src/pubspec.dart 366                     Pubspec._ensureEnvironment
     package:pub/src/pubspec.dart 331                     Pubspec.dartSdkConstraint
     package:pub/src/solver/backtracking_solver.dart 511  BacktrackingSolver._checkPubspecMatchesSdkConstraint
     package:pub/src/solver/backtracking_solver.dart 474  BacktrackingSolver._checkVersion
     ===== asynchronous gap ===========================
     package:pub/src/solver/backtracking_solver.dart 432  BacktrackingSolver._findValidVersion.<fn>
     ===== asynchronous gap ===========================
     dart:async                                           Future.doWhile
     package:pub/src/solver/backtracking_solver.dart 430  BacktrackingSolver._findValidVersion
     package:pub/src/solver/backtracking_solver.dart 337  BacktrackingSolver._versionQueueFor
     ===== asynchronous gap ===========================
     package:pub/src/solver/backtracking_solver.dart 290  BacktrackingSolver._solve.<fn>
     ===== asynchronous gap ===========================
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/backtracking_solver.dart 315  BacktrackingSolver._solve.<fn>
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 64
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 91     VersionSelection._addDependencies
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 91     VersionSelection._addDependencies
    ERR: This is an unexpected error. Please run
         pub --trace upgrade --verbosity io --no-precompile
     and include the logs in an issue on
  • Fix platform conflicts.

    Make sure none of the libraries use mutually exclusive dependendencies.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0