init static method

Future<SodiumSumo> init()

Creates a new SodiumSumo instance and initializes it

Internally, this method ensures the correct SodiumPlatform is available and then uses SodiumPlatform.loadSodiumSumo to create an instance. If the SodiumPlatform implementation does not support the advanced sumo APIs, this method will throw a SodiumSumoUnavailable exception.

In addition, when not running in release mode, it also performs a version check on the library to ensure you are using the correct native binary on platforms, where the binary is fetched dynamically.

Note: Calling this method multiple times will always return the same instance.

Implementation

static Future<SodiumSumo> init() => _instanceLock.synchronized(() async {
      if (_instance != null) {
        return _instance!;
      }

      _instance = await SodiumPlatform.instance.loadSodiumSumo();

      if (kDebugMode) {
        VersionCheck.check(SodiumPlatform.instance, _instance!);
      }

      return _instance!;
    });