play_games 0.1.0

  • Example
  • Installing
  • Versions
  • 71


Use Google Play Games Services on your Flutter app; this allows for signin and achievements so far, but more additions are very welcome. If you like it, give us a star and feel free to help and contribute.

Part 1: Sign In

Call the sign in method to sign in; you must check if the login was successufully.

    SigninResult result = await PlayGames.signIn();
    if (result.success) {
      await PlayGames.setPopupOptions();
      this.account = result.account;
    } else {
      this.error = result.message;
    this.loading = false;

But don't think it will be that easy! Actually, GPGS signin is quite a hassle to do, but this tutorial should help you out with this nefarious task.

Reasons for failure will be specified in the error property. Otherwhise, you can access the account property to get the account.

Part 2: Achievements

You can both award achievements (unlock/increment) and show the Achievements screen in your game.

In order to unlock or increment an achievement, use the provided APIs:


This is async and you wait for the return if desired. The name is the name in your games-ids.xml file, you can also call the by id method.

Also, there is a method to display a popup with your achievements:


Again, this is async and returns only when the player closes the popup. So maybe you want to pause your game until that happens.


  • First version, very basic signin and fetch avatar.


import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:play_games/play_games.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = (await PlayGames.signIn()).message;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        body: new Center(
          child: new Text('Running on: $_platformVersion\n'),

Use this package as a library

1. Depend on it

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

  play_games: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:play_games/play_games.dart';
Version Uploaded Documentation Archive
0.1.0 Sep 5, 2018 Go to the documentation of play_games 0.1.0 Download play_games 0.1.0 archive
0.0.1 Aug 26, 2018 Go to the documentation of play_games 0.0.1 Download play_games 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8