Flutter / Dart¶
IntelliVerseX Dart package for Flutter mobile apps, Dart CLIs, and server-side Dart workers. It layers typed helpers on top of the official nakama client for auth, economy, storage, RPC, optional realtime, AI, Discord social surfaces, Satori, Hiro live-ops, multiplayer lobbies, and deep links.
Requirements¶
- Dart SDK
>=3.0.0 <4.0.0(seeSDKs/flutter/pubspec.yaml) - Flutter stable channel recommended for mobile targets (iOS/Android)
- nakama Dart package
^1.3.0(declared as a direct dependency of this package)
Installation¶
Add to your pubspec.yaml:
dependencies:
intelliversex_sdk:
git:
url: https://github.com/Intelli-verse-X/Intelli-verse-X-SDK.git
path: SDKs/flutter
nakama: ^1.3.0
Or, once published to pub.dev:
Run:
Quick Start¶
import 'package:intelliversex_sdk/intelliversex_sdk.dart';
Future<void> main() async {
final ivx = IVXManager.instance;
ivx.on(IVXEvent.authSuccess, (userId) => print('Logged in: $userId'));
ivx.initialize(const IVXConfig(
nakamaHost: '127.0.0.1',
nakamaPort: 7350,
nakamaServerKey: 'defaultkey',
enableDebugLogs: true,
));
await ivx.authenticateDevice();
final profile = await ivx.fetchProfile();
final wallet = profile.wallet; // embedded in IVXProfile
final records = await ivx.fetchLeaderboard('weekly', limit: 20);
}
Hook multiplayer after session exists:
IVXMultiplayer.instance.initialize(ivx.client!, ivx.session!);
final lobbies = await IVXMultiplayer.instance.listLobbies();
API Surface¶
The library entry point is package:intelliversex_sdk/intelliversex_sdk.dart, which re-exports the files below.
| Type | Role |
|---|---|
IVXManager | Singleton: initialize, typed on/off for IVXEvent, auth, profile, wallet, leaderboards, storage, RPC, access to underlying Client / Session |
IVXConfig | Immutable config: host, port, server key, SSL, debug, optional gameId (validate() on init) |
IVXEvent | Enum: initialized, authSuccess, authError, profileLoaded, walletUpdated, leaderboardFetched, storageRead, rpcResponse, error |
IVXMultiplayer | Lobby create/join/list, matchmaking ticket start/cancel — RPC-backed (initialize(client, session) required) |
IVXGameModeManager | Local/game-mode state: slots, rooms, match flow (companion to multiplayer) |
IVXHiroSystems | Facade over Hiro subsystems: spin wheel, streaks, offerwall, retention, friend quests/battles, IAP trigger, smart ad timer |
IVXDiscordSocial | Discord config, friends, invites, voice/chat models |
IVXDiscordSettings, IVXDiscordMessages, IVXDiscordModeration, IVXDiscordLinkedChannels, IVXDiscordDebug | Discord feature slices |
IVXSatori, IVXSatoriConfig, … | Satori-style analytics types and client |
IVXAIClient, IVXAIAssistant, IVXAIContentGenerator, IVXAIModerator, IVXAINPCDialogManager, IVXAIProfiler, IVXAIVoiceServices | AI session, moderation, NPC dialog, voice |
IVXDeepLinks | Campaign / deferred deep link helpers |
IVXProfile, IVXLeaderboardRecord, IVXError | Shared DTOs (types.dart) |
Naming note: Hiro live-ops are exposed as IVXHiroSystems, not IVXHiroClient.
Feature coverage¶
Legend: Y = supported in this package layer, S = stub, partial, or server-dependent, — = not provided here (build yourself).
| Area | Flutter |
|---|---|
| Device / email / Google / Apple / custom auth | Y |
| Session restore from disk (built-in) | — (use shared_preferences + Session restore pattern yourself) |
| Profile / wallet / leaderboards / storage / RPC | Y |
| Real-time socket (full IVX wrapper) | S (use nakama socket APIs via IVXManager.client) |
| AI: init / voice / host-style client | Y |
| AI: hosted LLM orchestration | S |
Lobby / matchmaking (IVXMultiplayer) | Y |
Hiro systems (IVXHiroSystems) | Y |
| Discord stack | S |
Satori (IVXSatori) | S |
Deep links (IVXDeepLinks) | Y |
State management¶
The SDK is agnostic to UI frameworks. Use whichever pattern you already standardize on.
Provider (provider package)¶
class IvxHolder extends ChangeNotifier {
final IVXManager ivx = IVXManager.instance;
// call notifyListeners() from ivx.on handlers if you mirror state
}
Register a single ChangeNotifierProvider above MaterialApp and inject context.read<IvxHolder>() in screens.
Riverpod¶
For async auth:
final sessionProvider = FutureProvider<void>((ref) async {
final ivx = ref.read(ivxManagerProvider);
ivx.initialize(const IVXConfig(/* ... */));
await ivx.authenticateDevice();
});
Prefer ref.onDispose to off() event handlers if you register per-widget callbacks.
Bloc / Cubit¶
- Emit states from
IVXEventhandlers:authSuccess→Authenticated,authError→AuthFailed. - Keep
IVXManager.instanceoutside Bloc constructors if you unit-test withIVXManager.resetInstance()between tests.
General rules¶
- Never call
initializefrom every widgetbuild; do it once at app start (e.g. rootStatefulWidgetorAppInitializationfuture). - Subscribe to events in
initState/ providerbuildscope and cancel indispose/off()to avoid leaks. - Long-running
await ivx.authenticateDevice()should run beforerunAppor behind a splash screen FutureBuilder.
Advanced examples¶
Hiro “season pass” style UI (spin + streak + offerwall)¶
IVXHiroSystems is a singleton; call initialize(client, session) once after auth. Subsystems are nested fields (spinWheel, streaks, offerwall, …):
final ivx = IVXManager.instance;
final hiro = IVXHiroSystems.instance;
hiro.initialize(ivx.client!, ivx.session!);
final spin = await hiro.spinWheel.spin();
// bind spin.rewardType, spin.amount to a widget
final streak = await hiro.streaks.getState();
// show streak.currentStreak in your season-pass sheet
final offers = await hiro.offerwall.list();
// ListView.builder for IVXOffer tiles
Wrap calls in try/catch and map IVXError to SnackBar / AlertDialog. RPC ids are fixed in ivx_hiro_systems.dart (hiro_spin_wheel_spin, etc.) and must exist on your Nakama server.
AI assistant chat UI¶
IVXAIClient is also a singleton (IVXAIClient.instance). Voice-first flows use startVoiceSession; text uses sendText + pollMessages (or your own push channel):
final ai = IVXAIClient.instance;
await ai.initialize(
apiBaseUrl: 'https://api.example.com',
apiKey: secret,
);
final session = await ai.startVoiceSession('quiz_host', ivx.userId);
// For text-style UX on the same session:
await ai.sendText(session.sessionId, userInput);
final msgs = await ai.pollMessages(session.sessionId);
Drive a ListView from the latest IVXAIMessage list; throttle pollMessages (e.g. Timer.periodic) to avoid HTTP pile-ups.
Troubleshooting¶
dart pub get / flutter pub get fails¶
- Git path dependency: ensure the
url+path: SDKs/fluttermatch your fork layout; shallow clones may omit submodules if you use any. - Version solving failed: run
dart pub outdatedand alignnakamawith the range required byintelliversex_sdk. - Corporate proxy: configure
HTTPS_PROXYand pub’s hosted cache mirrors per Dart documentation.
iOS build / CocoaPods¶
- Run
cd ios && pod installafter adding or upgrading Flutter plugins. - If
nakamaor transitive pods require a higher iOS deployment target, setplatform :ios, '13.0'(or newer) inios/Podfileto match plugin minima. - Clean build folder:
flutter clean && flutter pub get.
Android minSdkVersion¶
- Nakama and HTTP stacks may require minSdk 21+; set
minSdkinandroid/app/build.gradleconsistently withcompileSdk. - For desugaring (older APIs), enable core library desugaring only if another dependency demands it.
Dart version conflicts¶
- Monorepos using Melos or path dependencies must use a single SDK constraint across packages; the IVX package requires Dart 3.
- CI images should pin
dart --versionto the same major.minor as local devs.
Session not surviving restarts¶
- The Flutter
IVXManagerdoes not automatically persist refresh tokens in all builds; persistsession.refreshToken/session.tokensecurely (e.g.flutter_secure_storage) and restore via nakama’s session APIs on cold start.
Features (summary)¶
| Feature | Status |
|---|---|
| Device Auth | Supported |
| Email Auth | Supported |
| Google Auth | Supported |
| Apple Auth | Supported |
| Custom Auth | Supported |
| Profile | Supported |
| Wallet / Economy | Supported |
| Leaderboards | Supported |
| Cloud Storage | Supported |
| RPC Calls | Supported |
| Hiro Systems | Via IVXHiroSystems + RPC |
| Multiplayer lobby | Via IVXMultiplayer + RPC |
| Dart Types | Full support in package |
Nakama client¶
Built on nakama — the official Heroic Labs Dart client. Use IVXManager.client and IVXManager.session for features not wrapped by IVX (matchmaker, realtime channel, groups).
Source¶
- SDKs/flutter/ —
lib/intelliversex_sdk.dart,lib/src/*.dart,pubspec.yaml, tests undertest/when present.
Further reading¶
- Nakama Dart client docs — authentication, sockets, and API surface.
- Flutter architectural overview — how to place initialization relative to widgets.
- IntelliVerseX skills:
.cursor/skills/ivx-sdk-setup/SKILL.md,.cursor/skills/ivx-quiz-content/SKILL.md,.cursor/skills/ivx-ai-integration/SKILL.md— content pipelines and AI configuration that complement mobile clients.