secrethero_flutter 1.0.0 copy "secrethero_flutter: ^1.0.0" to clipboard
secrethero_flutter: ^1.0.0 copied to clipboard

SecretHero Flutter SDK

Secret Hero Setup #

Description #

Secret Hero is a sdk designed to add gaming functionalities into your application. This SDK empowers developers to integrate engaging gameplay experiences, including leaderboard tracking and coupon rewards, enhancing user engagement and retention within your app.

Installation #

To integrate the SecretHero library into your project, add the following dependency as follows;

With Flutter:

$ flutter pub add secrethero_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  secrethero_flutter: "latest_version"

Setup #

Initialize Secret Hero #

  1. The initialize function within the SecretHero SDK is responsible for initializing the SDK with specific configuration settings and an listener to handle events and callbacks.

  2. The SecretHeroConfig class is responsible for the configuration initializing the SecretHero SDK.

SecretHero().initialize(secretHeroConfig, secretHeroListener)
SecretHeroConfig(
      token: "your_token",
      userId: "user_id",
      displayName: "display_name",
      theme: SecretHeroTheme(
        primaryColor: "#191D21",
        secondaryColor: "#FFFFFF",
        highlightColor: "#7B61FF",
        buttonColor: "#92FFD7",
      ));

SecretHero.initialize(config: config, delegate: self)
  • token: A token required for authentication and interaction with the SecretHero SDK.
  • userId: Represents the user ID associated with the SecretHero session.
  • displayName: An display name for the user within the SecretHero environment.
  • theme: SecretHeroTheme class encapsulates various visual attributes, allowing customization of the platform's appearance
  1. The SecretHeroEventListener delegate serves as a callback mechanism within the SecretHero SDK, providing methods to handle various events and responses during the SDK's lifecycle and operations.
final secretHeroListener = SecretHeroEventListener(
  onInitialized: () {
    print("onInitialized");
  },
  onInitializeFailed: (errorMessage) {
    print("onInitializeFailed $errorMessage");
  }, 
  onOpen: () {
    print("onOpen");
  }, 
  onClose: () {
    print("onClose");
  }, 
  onEvent: (event) {
    print("onEvent $event");
  });
  • onInitialized(): Invoked when the SecretHero SDK is successfully initialized.
  • onInitializeFailed(errorMessage: String) : Triggered upon initialization failure in the SecretHero SDK
  • onClose() : Called when the SecretHero session is closed or terminated
  • onOpen() : Executed when the SecretHero session is opened or activated
  • onEvent() : Executed when the SecretHeroEvent is accrued
  1. The release() function within the SecretHero serves the purpose of releasing and resetting configuration and listeners associated with the SecretHero. Need to be called onDestroy