play_game_service

A Google Play Games Services plugin for flutter

Getting Started

  1. add dependencies

     dependencies:
       play_game_service: ^0.2.2
    
  2. import requirements

     import 'package:play_game_service/play_game_service.dart';
    
  3. SignIn

     // set scopeSnapShot=false if you don't want play with snapshots;
     var ret = await PlayGameService.signIn(scopeSnapShot: true);
     if(ret.success){
       if(ret.email != null){
         // you can get user's email from ret.email
       }
     }
    
  4. Save Game Data

     var ret = await PlayGameService.saveSnapShot("HashiTogether", new Uint8List(10), "description");
     if(ret.success){
       // save successful
     }
    
  5. Load Game Data

     var ret = await PlayGameService.signIn(scopeSnapShot: true);
     if (ret.success) {
       var loadResult = await PlayGameService.loadSnapShot("HashiTogether");
       if (loadResult.success) {
         Uint8List data = loadResult.data!;
         // TODO Now you have data, do what you want.
       }
     }
    
  6. Show Leaderboards

     PlayGameService.showLeaderboards();
    
  7. Submit score

     // leaderBoardId is the leaderboard's id which you added in google play console
     PlayGameService.submitScore(leaderBoardId, count);
    
  8. Show Achievement

     PlayGameService.showAchievements();
    
  9. Achievement increment

     // ACHIEVEMENT_ID is the achievement's id which you added in google play console
     PlayGameService.increment(ACHIEVEMENT_ID);
    

Libraries

play_game_service