firebase_game_services 2.2.0-rc.1 copy "firebase_game_services: ^2.2.0-rc.1" to clipboard
firebase_game_services: ^2.2.0-rc.1 copied to clipboard

discontinued

A Flutter package, linking Google's Play Games and Apple's Game Center with Firebase.

example/lib/main.dart

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

getSignIn() async {
  try {
    await FirebaseGameServices.instance.signIn();
  } on Exception catch (e) {
    print(e);
  }
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  getSignIn();
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Example'),
        ),
        body: Center(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.showAchievements();
                    },
                    child: const Text("Achievements")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance
                          .showSingleLeaderboard();
                    },
                    child: const Text("Single Leaderboard with Id")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.showAllLeaderboards();
                    },
                    child: const Text("All Leaderboards")),
                ElevatedButton(
                    onPressed: () async {
                      var id =
                          await FirebaseGameServices.instance.getPlayerId();
                      print(id);
                    },
                    child: const Text("Player Id")),
                ElevatedButton(
                    onPressed: () async {
                      var name =
                          await FirebaseGameServices.instance.getPlayerName();
                      print(name);
                    },
                    child: const Text("Player Name")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.submitScore(
                          score: Score(
                        androidLeaderboardID: 'android_leaderboard_id',
                        iOSLeaderboardID: 'ios_leaderboard_id',
                        value: 5,
                      ));
                    },
                    child: const Text("Submit Score")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.unlock(
                        achievement: Achievement(
                            androidID: 'android_id',
                            iOSID: 'ios_id',
                            percentComplete: 100,
                            steps: 2),
                      );
                    },
                    child: const Text("Unlock Achievement")),

                // Platform Specific
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.showAccessPoint(
                        AccessPointLocation.topLeading,
                        showHighlights: true,
                      );
                    },
                    child: const Text("Show Accesspoint")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.showDashboard();
                    },
                    child: const Text("Presents the main dashboard")),
                ElevatedButton(
                    onPressed: () async {
                      await FirebaseGameServices.instance.showPlayerProfile();
                    },
                    child: const Text("Presents the player's profile")),
                ElevatedButton(
                    onPressed: () async {
                      var isUnderage =
                          await FirebaseGameServices.instance.isUnderage();
                      print(isUnderage);
                    },
                    child: const Text("isUnderage")),
                ElevatedButton(
                    onPressed: () async {
                      var isMultiplayerGamingRestricted =
                          await FirebaseGameServices.instance
                              .isMultiplayerGamingRestricted();
                      print(isMultiplayerGamingRestricted);
                    },
                    child: const Text("isMultiplayerGamingRestricted")),
                ElevatedButton(
                    onPressed: () async {
                      var isPersonalizedCommunicationRestricted =
                          await FirebaseGameServices.instance
                              .isPersonalizedCommunicationRestricted();
                      print(isPersonalizedCommunicationRestricted);
                    },
                    child: const Text("isPersonalizedCommunicationRestricted")),
              ]),
        ),
      ),
    );
  }
}
13
likes
0
points
80
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package, linking Google's Play Games and Apple's Game Center with Firebase.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_game_services_apple, firebase_game_services_google, firebase_game_services_platform_interface, flutter

More

Packages that depend on firebase_game_services