Search packages, repositories and app categories

Package detailsv0.3.0

google_sign_in_dartio

Flutter package for Google Sign-In built in dart and support both Mobile and Desktop environments.

AndroidiOSmacOS
30-day downloads
9.7K
Likes
29
Pub points
150

Install package

flutter pub add google_sign_in_dartio

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package enabling Google Sign-In using pure Dart, supporting Android, iOS, and macOS. It provides a cross-platform solution for authentication without relying on native code, simplifying integration across mobile and desktop environments. The package is designed for developers seeking a lightweight, unified approach to Google authentication in their Flutter apps.

Use cases

  • User authentication in cross-platform apps
  • Simplifying login flows for mobile and desktop
  • Integrating Google accounts in Flutter applications
  • Enabling secure sign-in without native dependencies
  • Supporting multi-platform identity management

Key features

  • Pure Dart implementation
  • Cross-platform support (Android, iOS, macOS)
  • No native code required
  • Lightweight and easy to integrate
  • Built-in handling of OAuth2 tokens

Suitable for

  • Developers targeting multiple platforms with shared authentication logic
  • Projects avoiding platform-specific native code
  • Apps requiring seamless Google Sign-In on desktop and mobile
  • Teams prioritizing code consistency across platforms
  • Applications needing minimal setup for Google authentication

Considerations

  • Limited to Google Sign-In only
  • Requires proper configuration in Google Cloud Console
  • May have fewer features compared to platform-specific SDKs
  • Depends on internet connectivity for authentication
  • Not suitable for complex OAuth workflows beyond basic sign-in

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

google_sign_in_dartio

A Flutter package that implements Google Sign In in pure Dart. This package is compatible with google_sign_in plugin and works on all platforms Flutter supports but it's intended to be mainly used on Desktop.

Getting Started

Install and initialization
  1. Depend on it
    dependencies:
      google_sign_in: ^4.1.4
      google_sign_in_dartio: ^0.0.6
    
  2. Run flutter pub get
  3. Import
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
  4. Register the package
    import 'package:flutter/material.dart';
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
    void main() {
      if (isDesktop) {
        GoogleSignInDart.register(clientId: <clientId>);
      }
    
      runApp(MyApp());
    }
    
    Note: You might want to await for the register method to finish before calling any GoogleSignIn methods when your app starts.
Usage

You can use the normal GoogleSignIn methods.

final GoogleSignInAccount account = await GoogleSignIn().signIn();

Obtain a Client ID for your Desktop app

  1. Go to the Google Cloud Platform console and select you project
  2. Go to APIs & Service -> Credentials
  3. Create new credentials for your app by selecting CREATE CREDENTIALS and then OAuth client ID
  4. Select Other as Application type, give it a name (eg. macOS) and then click Create
Provide a code exchange endpoint

The user accessToken expires after about one hour, after witch you need to ask the user to login again. If you want to keep the user logged in, you need to deploy a oAuth code exchange endpoint. Once you have your endpoint you can register the package like this.

NOTE:

If you use this only for FirebaseAuth you don't need the code exchange since the token must be valid only when you use the signInWithCredentials method.

    import 'package:flutter/material.dart';
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
    void main() {
      if (isDesktop) {
        GoogleSignInDart.register(
            clientId: <clientId>, 
            exchangeEndpoint: <endpoint>,
        );
      }
    
      runApp(MyApp());
    }
NOTE:

GoogleSignInTokenData exposes serverAuthCode field that should contain the exchange code from the authorization request. This will always be null when using this package because we already allow you to provide a code exchange endpoint witch exposes the code and code verifier in a trusted environment and encourages not to do the code exchange on the client.

See instruction on how to deploy a code exchange endpoint.

Categories

Dependencies

Dependency list 10 items

Source repository

Projects using this package

No data available yet.