Initialize the SDK
Initialize Gameball once, usually at app startup in your main() function:
import 'package:gameball_sdk/gameball_sdk.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final config = GameballConfig.builder()
.apiKey("your-api-key") // Required
.lang("en") // Required
.platform("flutter") // Optional
.shop("your-shop-id") // Optional
.sessionToken("your-session-token") // Optional - for v4.1 endpoints
.apiPrefix("custom-prefix") // Optional
.build();
final gameballApp = GameballApp.getInstance();
gameballApp.init(config);
runApp(MyApp());
}
Configuration Parameters
The client API key available in your Gameball dashboard (required).
The language code for SDK localization (e.g., “en”, “ar”, “fr”). Required.
Platform identifier, defaults to “flutter”.
Your Gameball shop identifier for multi-shop configurations.
Session Token for secure authentication (enables automatic v4.1 endpoint routing).
Custom API endpoint prefix for advanced configurations.
Validation Rules
GameballConfig requires:
- API key is required (cannot be null)
- Language is required (cannot be null)
Example
import 'package:flutter/material.dart';
import 'package:gameball_sdk/gameball_sdk.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Gameball SDK
final config = GameballConfig.builder()
.apiKey("gb_live_xxxxxxxxxxxxxxxx")
.lang("en")
.platform("flutter")
.shop("myshop")
.sessionToken("your-session-token") // Optional
.build();
final gameballApp = GameballApp.getInstance();
gameballApp.init(config);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Gameball Demo',
home: HomeScreen(),
);
}
}
Call init() before running your app to ensure the SDK is ready when your app starts.
Make sure to use your actual API key from the Gameball dashboard. Test keys are for development, production keys are for live deployment.
Next Steps