I am creating a flutter game which utilise the Google play games. I use the game_services package.
When I tried to signIn, the logs says like this:
code:
void signin() async {
try {
print('account before: $account');
account = await GamesServices.signIn();
print('account: $account');
} catch (e) {
print('Error on signing: $e');
}
}
@override
void initState() {
signin();
super.initState();
}
Logs:
I/PlayService( 2169): isAuthenticated: true toString: com.google.android.gms.games.AuthenticationResult@c64b8d0 I/signin ( 2169): success I/flutter ( 2169): account: null
You can see even after saying success, the account String is empty.
I had completed these steps
game_services
packageAndroidManifest
I want to know why account
is null.
I solved it by changing the code like this:
try {
await GamesServices.signIn();
if (await GamesServices.isSignedIn) {
// user is signed
}
}
Also make sure you added the SHA1 fingerprint of both debug and production inside the Credentials (OAuth Clients).