Optional setup
The AffiseSettings builder returned by Affise.settings(...) exposes fluent methods that mirror fields on AffiseInitProperties. All methods return the same AffiseSettings instance so you can chain them before start().
AffiseSettings builder
Section titled “AffiseSettings builder”All declared in lib/settings/affise_settings.dart:
| Method | Line |
|---|---|
| setProduction(bool production) | :30 |
| setDomain(String domain) | :36 |
| setPartParamName(String partParamName) | :42 |
| setPartParamNameToken(String partParamNameToken) | :48 |
| setAppToken(String appToken) | :54 |
| setOnInitSuccess(OnInitSuccessHandler onInitSuccessHandler) | :72 |
| setOnInitError(OnInitErrorHandler onInitErrorHandler) | :78 |
| setConfigValue(AffiseConfig key, dynamic value) | :84 |
| setConfigValues(Map<AffiseConfig, dynamic> values) | :90 |
| setDisableModules(List<AffiseModules> disableModules) | :98 |
| start() | :122 |
Production mode and custom domain
Section titled “Production mode and custom domain”Affise .settings( affiseAppId: "Your appId", secretKey: "Your SDK secretKey", ) .setProduction(false) .setDomain("https://YoureCustomDomain/") // Set custom domain .start(); // Start Affise SDKInit callbacks
Section titled “Init callbacks”Affise .settings( affiseAppId: "Your appId", secretKey: "Your SDK secretKey", ) .setOnInitSuccess(() { // Called if library initialization succeeded print("Affise: init success"); }) .setOnInitError((error) { // Called if library initialization failed print("Affise: init error $error"); }) .start(); // Start Affise SDKCallback typedefs:
typedef OnInitSuccessHandler = void Function();(lib/settings/on_init_success_handler.dart:1)typedef OnInitErrorHandler = void Function(String e);(lib/settings/on_init_error_handler.dart:1)
Config values — AffiseConfig
Section titled “Config values — AffiseConfig”enum AffiseConfig { FB_APP_ID;}Declared at lib/settings/affise_config.dart:3-10. Native key mapping (:12-19): AffiseConfig.FB_APP_ID → "fb_app_id".
The FB_APP_ID value is consumed by the Meta module:
Affise .settings( affiseAppId: "Your appId", secretKey: "Your SDK secretKey", ) .setConfigValue(AffiseConfig.FB_APP_ID, "Your Facebook App Id") .start(); // Start Affise SDKDisable modules at startup
Section titled “Disable modules at startup”Affise .settings( affiseAppId: "Your appId", secretKey: "Your SDK secretKey", ) .setDisableModules([ // Exclude modules from start AffiseModules.ADVERTISING, AffiseModules.SUBSCRIPTION, ]) .start(); // Start Affise SDKEnumeration: see Modules overview.
AffiseInitProperties
Section titled “AffiseInitProperties”Declared in lib/affise_init_properties.dart:9-54. All fields are exposed by the builder methods above.
| Field | Dart type | Default | Line |
|---|---|---|---|
| affiseAppId | String? | null (constructor required) | :10, ctor :25 |
| isProduction | bool | true | :11, ctor :27 |
| partParamName | String? | null | :12, ctor :28 |
| partParamNameToken | String? | null | :13, ctor :29 |
| appToken | String? | null | :14, ctor :30 |
| secretKey | String? | null (constructor required) | :15, ctor :26 |
| autoCatchingClickEvents | List<AutoCatchingType>? | null (ctor arg commented out) | :16, ctor :32 |
| enabledMetrics | bool | false (ctor arg commented out) | :17, ctor :31 |
| domain | String? | null | :18, ctor :33 |
| onInitSuccessHandler | OnInitSuccessHandler? | null | :19, ctor :34 |
| onInitErrorHandler | OnInitErrorHandler? | null | :20, ctor :35 |
| configValues | Map<AffiseConfig, dynamic> | const {} | :21, ctor :36 |
| disableModules | List<AffiseModules> | const [] | :22, ctor :37 |
The toMap getter (lib/affise_init_properties.dart:40-54) sends these keys to native: affiseAppId, isProduction, partParamName, partParamNameToken, appToken, secretKey, autoCatchingClickEvents, enabledMetrics, domain, configStrings, disableModules.
Changing the secret at runtime
Section titled “Changing the secret at runtime”Affise.setSecretKey("new secret");Signature: lib/affise.dart:49. Dispatches AffiseApiMethod.SET_SECRET_KEY (lib/native/affise_native.dart:75-77).