vgk_game_services 1.3.3 copy "vgk_game_services: ^1.3.3" to clipboard
vgk_game_services: ^1.3.3 copied to clipboard

outdated

A new Flutter plugin to support game center and google play games services.

example/lib/main.dart

// ignore_for_file: avoid_print, use_key_in_widget_constructors
import 'package:flutter/material.dart';
import 'package:vgk_game_services/games_services_platform_interface/models/access_point_location.dart';
import 'package:vgk_game_services/games_services_platform_interface/models/achievement.dart';
import 'package:vgk_game_services/games_services_platform_interface/models/score.dart';
import 'package:vgk_game_services/vgk_game_services.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Games Services plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              ElevatedButton(
                child: const Text('signIn1'),
                onPressed: () async {
                  final result = await VgkGameServices.signIn();
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Show Achievements'),
                onPressed: () async {
                  final result = await VgkGameServices.showAchievements();
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Show Leaderboards'),
                onPressed: () async {
                  final result = await VgkGameServices.showLeaderboards(
                      iOSLeaderboardID: 'ios_leaderboard_id');
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Submit Score'),
                onPressed: () async {
                  final result = await VgkGameServices.submitScore(
                      score: Score(
                          androidLeaderboardID: 'android_leaderboard_id',
                          iOSLeaderboardID: 'ios_leaderboard_id',
                          value: 5));
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Unlock'),
                onPressed: () async {
                  final result = await VgkGameServices.unlock(
                      achievement: Achievement(
                          androidID: 'android_id',
                          iOSID: 'ios_id',
                          percentComplete: 100));
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Increment'),
                onPressed: () async {
                  final result = await VgkGameServices.increment(
                      achievement:
                          Achievement(androidID: 'android_id', steps: 50));
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Show AccessPoint (iOS only)'),
                onPressed: () async {
                  final result = await VgkGameServices.showAccessPoint(
                      AccessPointLocation.topLeading);
                  print(result);
                },
              ),
              ElevatedButton(
                child: const Text('Get player id'),
                onPressed: () async {
                  final result = await VgkGameServices.getPlayer();
                  print(result);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin to support game center and google play games services.

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on vgk_game_services