unified_game_services_platform_interface
The common platform interface for
unified_game_services.
This package defines the contract that every game-service provider implements,
plus the shared models, capabilities, events and exceptions. Most apps don't
depend on it directly — they use unified_game_services (which re-exports
everything here) and a provider package. Depend on it directly only when
writing a provider.
Pure Dart, no Flutter dependency.
What's inside
UnifiedGameServicesPlatform— the abstract base every provider extends. Methods default to throwingUnimplementedError, so a provider overrides only what it supports.- Models —
Achievement,Leaderboard/LeaderboardEntry,PlayerProfile,Stat,CloudSave,RichPresence. Serialization viadart_mappable(toMap/toJson/copyWith/equality for free). GameCapability— the capability enum used for feature gating.- Events — a sealed
GameServiceEventhierarchy. - Exceptions —
GameServiceExceptionand subtypes (NotSignedIn,SignInFailed,CapabilityNotSupported,Network,PlatformOperation).
Install
dependencies:
unified_game_services_platform_interface: ^0.1.0
dev_dependencies:
build_runner: ^2.4.13
dart_mappable_builder: ^4.3.0
Writing a provider
import 'package:unified_game_services_platform_interface/unified_game_services_platform_interface.dart';
class MyProvider extends UnifiedGameServicesPlatform {
@override
Set<GameCapability> get capabilities => const {GameCapability.achievements};
@override
Future<void> unlockAchievement(String id) async {
// talk to your platform / backend
}
}
// Register it, or pass it to UnifiedGameServices(providers: [...]).
UnifiedGameServicesPlatform.instance = MyProvider();
Guidelines:
- Override only the methods your platform supports.
- Declare accurate
capabilities; throwCapabilityNotSupportedExceptionfor unsupported operations. - Map platform/SDK errors onto the
GameServiceExceptionhierarchy. - Put non-portable, provider-specific features as extra public members (not on
the interface). Apps reach them with
UnifiedGameServicesPlatform.getInstance<MyProvider>().
If you add or change a model, regenerate the dart_mappable code:
dart run build_runner build
(Generated *.mapper.dart files are committed so consumers don't need
build_runner.)
License
MIT — see the LICENSE file.
This is an independent, unofficial library, not affiliated with or endorsed by
any platform vendor. Third-party credits, trademark notices, and the Steamworks
SDK redistribution terms are in the repository's NOTICE.md.
Libraries
- unified_game_services_platform_interface
- The shared contract every
unified_game_servicesprovider implements: the UnifiedGameServicesPlatform base class, plus the models, capability set, event hierarchy, and normalized exceptions all providers share.