playtesters_sdk 0.3.0 copy "playtesters_sdk: ^0.3.0" to clipboard
playtesters_sdk: ^0.3.0 copied to clipboard

PlatformAndroid

Official client SDKs for integrating mobile applications with the https://playtesters.dev closed-testing platform.

example/main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize the SDK with your app's API key
  await Playtesters.configure(apiKey: 'ak_sample_app_key');

  runApp(const PlaytestersExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Playtesters SDK Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const ExampleHomeScreen(),
    );
  }
}

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

  @override
  State<ExampleHomeScreen> createState() => _ExampleHomeScreenState();
}

class _ExampleHomeScreenState extends State<ExampleHomeScreen> {
  @override
  void initState() {
    super.initState();

    // Check tester session on startup:
    // reads referrer, checks active campaign status, prompts dialog if needed
    WidgetsBinding.instance.addPostFrameCallback((_) {
      Playtesters.checkTestSession(context);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Playtesters Example'),
      ),
      body: Column(
        children: [
          // Optional badge showing active tester session status
          const PlaytestersBadge(),
          Expanded(
            child: Center(
              child: Padding(
                padding: const EdgeInsets.all(24.0),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    ElevatedButton.icon(
                      onPressed: () async {
                        // Log custom tracking event
                        await Playtesters.log({'action': 'button_clicked'});
                        if (context.mounted) {
                          ScaffoldMessenger.of(context).showSnackBar(
                            const SnackBar(content: Text('Event logged!')),
                          );
                        }
                      },
                      icon: const Icon(Icons.touch_app),
                      label: const Text('Log Analytics Event'),
                    ),
                    const SizedBox(height: 16),
                    FilledButton.icon(
                      onPressed: () async {
                        // Mark test milestone achieved for credit
                        await Playtesters.achieved({'screen': 'completed'});
                        if (context.mounted) {
                          ScaffoldMessenger.of(context).showSnackBar(
                            const SnackBar(
                              content: Text('Goal achieved marked!'),
                            ),
                          );
                        }
                      },
                      icon: const Icon(Icons.check_circle),
                      label: const Text('Mark Goal Achieved'),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
0
likes
160
points
147
downloads

Documentation

API reference

Publisher

verified publisherplaytesters.dev

Weekly Downloads

Official client SDKs for integrating mobile applications with the https://playtesters.dev closed-testing platform.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http, package_info_plus, play_install_referrer, shared_preferences

More

Packages that depend on playtesters_sdk