initSdk method

Future<Result<bool>> initSdk({
  1. List<VKScope>? scope,
  2. List<String>? customScope,
})

Initialize SDK.

Should call before any other method calls.

You can pass scope (and/or customScope, see logIn) to require listed permissions. If user logged in, but doesn't have all of this permissions - he will be logged out.

Implementation

Future<Result<bool>> initSdk(
    {List<VKScope>? scope, List<String>? customScope}) async {
  final scopeArg = _getScope(scope: scope, customScope: customScope);

  if (debug) {
    final log = StringBuffer('initSdk');
    if (scopeArg != null) log.write('. Permissions: $scopeArg');
  }

  try {
    final result = await _channel.invokeMethod<bool>(_methodInitSdk, {
      _argInitSdkScope: scopeArg,
    });

    if (result == true) {
      _initialized = true;
      return Result.value(true);
    } else {
      _initialized = false;
      return Result.error('Init SDK failed');
    }
  } on PlatformException catch (e) {
    if (debug) _log('Init SDK error: $e');
    return Result.error(e);
  }
}