ReownAppKitModal constructor

ReownAppKitModal({
  1. required BuildContext context,
  2. IReownAppKit? appKit,
  3. String? projectId,
  4. PairingMetadata? metadata,
  5. SIWEConfig? siweConfig,
  6. Map<String, RequiredNamespace>? requiredNamespaces,
  7. Map<String, RequiredNamespace>? optionalNamespaces,
  8. Set<String>? featuredWalletIds,
  9. Set<String>? includedWalletIds,
  10. Set<String>? excludedWalletIds,
  11. bool? enableAnalytics,
  12. bool enableEmail = false,
  13. List<ReownAppKitModalNetworkInfo> blockchains = const [],
  14. LogLevel logLevel = LogLevel.nothing,
})

Implementation

ReownAppKitModal({
  required BuildContext context,
  IReownAppKit? appKit,
  String? projectId,
  PairingMetadata? metadata,
  SIWEConfig? siweConfig,
  Map<String, RequiredNamespace>? requiredNamespaces,
  Map<String, RequiredNamespace>? optionalNamespaces,
  Set<String>? featuredWalletIds,
  Set<String>? includedWalletIds,
  Set<String>? excludedWalletIds,
  bool? enableAnalytics,
  bool enableEmail = false,
  List<ReownAppKitModalNetworkInfo> blockchains = const [],
  LogLevel logLevel = LogLevel.nothing,
}) {
  if (appKit == null) {
    if (projectId == null) {
      throw ReownAppKitModalException(
        'Either a `projectId` and `metadata` must be provided or an already created `appKit`',
      );
    }
    if (metadata == null) {
      throw ReownAppKitModalException(
        '`metadata:` parameter is required when using `projectId:`',
      );
    }
  }
  // if (siweConfig?.enabled == true && context == null) {
  //   throw ReownAppKitModalException(
  //     '`context:` parameter is required if using `siweConfig:`. Also, `context:` parameter will be enforced in future versions.',
  //   );
  // }

  _context = context;

  _appKit = appKit ??
      ReownAppKit(
        core: ReownCore(projectId: projectId!),
        metadata: metadata!,
      );
  _projectId = _appKit.core.projectId;

  _setRequiredNamespaces(requiredNamespaces);
  _setOptionalNamespaces(optionalNamespaces);

  uriService.instance = UriService(
    core: _appKit.core,
  );

  analyticsService.instance = AnalyticsService(
    core: _appKit.core,
    enableAnalytics: enableAnalytics,
  )..init().then((_) {
      analyticsService.instance.sendEvent(ModalLoadedEvent());
    });

  explorerService.instance = ExplorerService(
    core: _appKit.core,
    referer: _appKit.metadata.name.replaceAll(' ', ''),
    featuredWalletIds: featuredWalletIds,
    includedWalletIds: includedWalletIds,
    excludedWalletIds: excludedWalletIds,
  );

  blockchainService.instance = BlockChainService(
    core: _appKit.core,
  );

  magicService.instance = MagicService(
    core: _appKit.core,
    metadata: _appKit.metadata,
    enabled: enableEmail,
  );

  coinbaseService.instance = CoinbaseService(
    core: _appKit.core,
    metadata: _appKit.metadata,
    enabled: _initializeCoinbaseSDK,
  );

  siweService.instance = SiweService(
    appKit: _appKit,
    siweConfig: siweConfig,
  );
}