Skip to main content

klujo_flutter 0.0.2 copy "klujo_flutter: ^0.0.2" to clipboard
klujo_flutter: ^0.0.2 copied to clipboard

Engage your audience with interactive word games that capture attention, drive retention, and deliver real growth.

Klujo Flutter SDK #

pub package pub points

Integrate Klujo Games into your Flutter mobile applications. This SDK provides components for displaying interactive word games and a rewards system to engage your users.

Table of Contents #

Compatibility #

Platform / Technology Version Notes
Flutter >= 1.17.0 Supports all platforms
Dart >= 3.9.2 Null safety required
iOS 12.0+ Requires WebView support
Android API 21+ Requires WebView support

Installation #

Add the SDK to your Flutter project:

flutter pub add klujo_flutter

Or add it manually to your pubspec.yaml:

dependencies:
  klujo_flutter: ^0.0.1

Then run:

flutter pub get

Required Dependencies #

The SDK requires the following dependencies (automatically installed):

  • http: ^1.2.0 - HTTP client for API requests
  • webview_flutter: ^4.4.2 - WebView for game and rewards components
  • shared_preferences: ^2.2.0 - Persistent storage for player sessions

iOS Setup #

For iOS, add the following to your ios/Runner/Info.plist to enable WebView:

<key>io.flutter.embedded_views_preview</key>
<true/>

Android Setup #

For Android, ensure your android/app/build.gradle has minSdkVersion 21 or higher.

Getting Started #

Before using any SDK functionality, you need:

  • API Key: Your authentication key for the Klujo platform

You can obtain your API key from your Klujo Dashboard.

SDK Initialization #

Initialize the SDK before using any components or methods. This should be done once when your app starts, typically in your root widget's initState.

import 'package:klujo_flutter/klujo_flutter.dart';

// Basic initialization
final sdk = KlujoSDK();
final playerUUID = await sdk.initialization(
  apiKey: 'YOUR_API_KEY',
);

// With all options
final playerUUID = await sdk.initialization(
  apiKey: 'YOUR_API_KEY',
  playerUUID: 'existing-uuid',       // Optional: restore existing player
  externalId: 'your-internal-id',    // Optional: your system's user ID
  environment: Environment.production, // Optional: production or development
);

Parameters #

Parameter Type Required Description
apiKey String Yes Your Klujo API key
playerUUID String? No Existing player UUID to restore session
externalId String? No Your internal user identifier
environment Environment No API environment (default: production)

Environment Options #

enum Environment {
  production,   // Live Klujo services (default)
  development,  // Development/testing services
}

Returns #

Returns a Future<String> that resolves with the player's UUID. The SDK automatically persists this UUID to restore player sessions in future app launches.

Player Authentication #

After initialization, you can optionally authenticate the player with their profile information. This links the anonymous player session to a user identity.

import 'package:klujo_flutter/klujo_flutter.dart';

final sdk = KlujoSDK();
final playerUUID = await sdk.authentication(
  email: 'user@example.com',
  fullName: 'John Doe',
);

Parameters #

Parameter Type Required Description
email String? No Player's email address
fullName String? No Player's full name

Note: At least one parameter should be provided for meaningful authentication.

Returns #

Returns a Future<String> that resolves with the player's UUID.

Components #

KlujoGame #

A component that displays Klujo games in a WebView.

import 'package:klujo_flutter/klujo_flutter.dart';

// Basic usage
KlujoGame()

// With custom styling and loading indicator
KlujoGame(
  style: BoxDecoration(color: Colors.white),
  showLoading: true,
)

Props

Prop Type Default Description
style BoxDecoration? null Custom decoration for the container
showLoading bool true Show loading indicator while game loads

Example

import 'package:flutter/material.dart';
import 'package:klujo_flutter/klujo_flutter.dart';

class GameScreen extends StatelessWidget {
  const GameScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          const Positioned.fill(
            child: KlujoGame(showLoading: true),
          ),
        ],
      ),
    );
  }
}

KlujoRewards #

A floating action button that opens a modal displaying the player's rewards. The button appearance is customizable from your Klujo Dashboard.

import 'package:klujo_flutter/klujo_flutter.dart';

// Basic usage (bottom-left, compressed)
KlujoRewards()

// Custom position and expanded state
KlujoRewards(
  position: KlujoRewardsPosition.bottomRight,
  compressed: false,
)

Props

Prop Type Default Description
position KlujoRewardsPosition KlujoRewardsPosition.bottomLeft Position of the floating button
compressed bool true Initial state - true shows only icon, false shows icon + text

Position Options

enum KlujoRewardsPosition {
  bottomLeft,   // Fixed to bottom-left corner
  bottomRight,  // Fixed to bottom-right corner
  topLeft,      // Fixed to top-left corner
  topRight,     // Fixed to top-right corner
}

Example

import 'package:flutter/material.dart';
import 'package:klujo_flutter/klujo_flutter.dart';

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          // Your app content
          const Center(child: Text('Welcome!')),

          // Floating rewards button
          const KlujoRewards(
            position: KlujoRewardsPosition.bottomRight,
            compressed: true,
          ),
        ],
      ),
    );
  }
}

Complete Example #

Here's a complete example showing SDK initialization, authentication, and component usage:

import 'package:flutter/material.dart';
import 'package:klujo_flutter/klujo_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Klujo Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF6366F1)),
        useMaterial3: true,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  bool _isInitialized = false;
  bool _showGame = false;
  String? _error;

  @override
  void initState() {
    super.initState();
    _initializeKlujo();
  }

  Future<void> _initializeKlujo() async {
    try {
      // Initialize the SDK
      final sdk = KlujoSDK();
      final playerUUID = await sdk.initialization(
        apiKey: 'YOUR_API_KEY',
        externalId: 'user-123',
        environment: Environment.production,
      );

      debugPrint('Player UUID: $playerUUID');

      // Optionally authenticate with user profile
      await sdk.authentication(
        email: 'user@example.com',
        fullName: 'John Doe',
      );

      setState(() => _isInitialized = true);
    } catch (e) {
      setState(() => _error = 'Failed to initialize Klujo SDK');
      debugPrint('Error: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    if (_error != null) {
      return Scaffold(
        body: Center(
          child: Text(_error!, style: const TextStyle(color: Colors.red)),
        ),
      );
    }

    if (!_isInitialized) {
      return const Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              CircularProgressIndicator(),
              SizedBox(height: 16),
              Text('Initializing...'),
            ],
          ),
        ),
      );
    }

    if (_showGame) {
      return Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: const Icon(Icons.arrow_back),
            onPressed: () => setState(() => _showGame = false),
          ),
          title: const Text('Klujo Game'),
        ),
        body: const KlujoGame(showLoading: true),
      );
    }

    return Scaffold(
      body: Stack(
        children: [
          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text(
                  'Welcome to Klujo!',
                  style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
                ),
                const SizedBox(height: 20),
                ElevatedButton(
                  onPressed: () => setState(() => _showGame = true),
                  child: const Text('Play Game'),
                ),
              ],
            ),
          ),

          // Floating rewards button
          const KlujoRewards(position: KlujoRewardsPosition.bottomRight),
        ],
      ),
    );
  }
}

Type Definitions #

Environment #

enum Environment {
  production,
  development,
}

KlujoRewardsPosition #

enum KlujoRewardsPosition {
  bottomLeft,
  bottomRight,
  topLeft,
  topRight,
}

RewardSettings #

Server-configured settings for the rewards button appearance:

class RewardSettings {
  final String? buttonText;           // Button label text
  final String? buttonBackgroundColor; // Button background color (hex)
  final String? primaryColor;         // Text color (hex)
  final String? buttonIcon;           // Button icon/emoji
  // ... additional configuration options
}

Support #

For questions, issues, or feature requests:

License #

This SDK is proprietary software. Unauthorized use, copying, modification, or distribution is strictly prohibited without prior written consent from Klujo.

For licensing inquiries, contact info@klujo.com.


Made with care by the Klujo Team

0
likes
0
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Engage your audience with interactive word games that capture attention, drive retention, and deliver real growth.

Homepage
Repository

License

unknown (license)

Dependencies

flutter, http, shared_preferences, url_launcher, webview_flutter

More

Packages that depend on klujo_flutter