unified_game_services_google_play_flutter 0.1.0 copy "unified_game_services_google_play_flutter: ^0.1.0" to clipboard
unified_game_services_google_play_flutter: ^0.1.0 copied to clipboard

Flutter adapter for unified_game_services Google Play Games — auto-resolves the Android Activity from the running Flutter engine for plug-and-play registration.

unified_game_services_google_play_flutter #

Flutter adapter for the unified_game_services Google Play Games family.

The provider packages are pure Dart and require the host to hand them the Android Activity jobject. This is the only package in the family that depends on Flutter: it resolves that activity from the running Flutter engine (via jni_flutter), giving you plug-and-play registration — no PlatformDispatcher / jni_flutter wiring in your app code.

If you are building a Flutter app, this is the package you want.

Which package do I use? #

Your app Package
Flutter app (any platform) this package (unified_game_services_google_play_flutter)
Non-Flutter, multi-platform (game engine / CLI / server) — native on Android, REST elsewhere unified_game_services_google_play
Android only, non-Flutter host, want native toasts unified_game_services_google_play_android
Cloud REST tier — any platform incl. Android (NDK), no native toasts unified_game_services_google_play_rest

Usage #

import 'package:flutter/material.dart';
import 'package:unified_game_services/unified_game_services.dart';
import 'package:unified_game_services_google_play_flutter/unified_game_services_google_play_flutter.dart';

void main() {
  // Android: auto-resolves the Activity and wires the native Play Games
  // provider (native toasts/overlay). Off Android — including Flutter web —
  // pass `auth:` for the REST path.
  GooglePlayGamesFlutter.registerWith(
    achievementIds: {'firstWin': 'CgkI...'},
    leaderboardIds: {'highScores': 'CgkI...'},
  );
  runApp(const MyApp());
}

// Anywhere in the app:
final games = UnifiedGameServices(); // uses the registered instance
await games.unlockAchievement('firstWin');

GooglePlayGamesFlutter.registerWith sets UnifiedGameServicesPlatform.instance. GooglePlayGamesFlutter.create returns the provider without registering it (for the multi-provider facade: UnifiedGameServices(providers: [...])).

This package re-exports the whole family API (unified_game_services_google_play), so the single import above also gives you GooglePlayAndroidProvider, GooglePlayGamesProvider, and the REST AuthStrategy types.

Why a separate package #

The family enforces pure Dart, no Flutter so the providers work in CLIs, servers, and non-Flutter game engines. jni_flutter is a Flutter plugin — it cannot live in the pure-Dart packages. This adapter quarantines the Flutter dependency: Flutter apps add it, everyone else uses the pure-Dart packages directly and supplies their own activityResolver.

Android setup #

Same as the native provider: bundle the Play Games v2 aar and declare the app id. See example/ (carries the play-services-games-v2 gradle dependency and the com.google.android.gms.games.APP_ID manifest meta-data).

Web & other platforms #

jni_flutter / package:jni (no web support) sit behind a dart.library.io conditional import, so this adapter compiles and runs on Flutter web (and desktop): off Android it takes the REST path and needs an auth: [AuthStrategy]. On web, broker a token (your own redirect-based OAuth or a backend) and pass it via StoredCredentialStrategy — the interactive LoopbackOAuthStrategy is desktop/CLI only.

0
likes
160
points
8
downloads

Documentation

API reference

Publisher

verified publisheraprimo.dev

Weekly Downloads

Flutter adapter for unified_game_services Google Play Games — auto-resolves the Android Activity from the running Flutter engine for plug-and-play registration.

Repository (GitHub)
View/report issues

Topics

#game-services #google-play-games #flutter #achievements #leaderboards

License

MIT (license)

Dependencies

flutter, jni, jni_flutter, unified_game_services_google_play, unified_game_services_google_play_android, unified_game_services_platform_interface

More

Packages that depend on unified_game_services_google_play_flutter