configureWithResult static method
Initializes the SDK with the specified configuration.
The configuration is applied through the native platforms. This method returns a boolean result instead of throwing exceptions for initialization failures. Use configure if you prefer exception-based error handling.
When switching App IDs, abortOnError controls behavior if flushing
unsent data fails:
true(default): Rollback to previous App ID on flush failure. Returnsfalse.false: Continue with App ID switch even if flush fails. Returnstrue.
This parameter only affects App ID switching scenarios.
-
Parameters:
- config: A map containing initialization settings, such as API keys, environment flags, or other required parameters.
- abortOnError: Controls behavior when flushing unsent data fails during
App ID switching. Default is
true.
-
Returns: A Future that completes with
trueon success, orfalseon failure. Returnsfalsein the following cases:- Invalid App ID (null, empty, or whitespace only)
- Already configuring (previous call not yet completed)
- Native initialization failure when
abortOnError = true(rollback occurred) - Platform communication errors
This method never throws exceptions; all errors are indicated by returning
false. Use configure if you prefer exception-based error handling.
This method behaves similarly to the iOS initialize API with
abortOnError = true.
Implementation
static Future<bool> configureWithResult(
Map<String, dynamic> config, {
bool abortOnError = true,
}) async {
final appId = config[appIdKey] as String?;
if (appId == null || appId.trim().isEmpty) {
print('APPIER: Invalid AppId passed');
return false;
}
return AppierFlutterPlatform.instance
.configureWithResult(config, abortOnError: abortOnError);
}