ReownAppKitModal constructor

ReownAppKitModal({
  1. required BuildContext context,
  2. IReownAppKit? appKit,
  3. String? projectId,
  4. PairingMetadata? metadata,
  5. bool? enableAnalytics,
  6. SIWEConfig? siweConfig,
  7. FeaturesConfig? featuresConfig,
  8. @Deprecated('requiredNamespaces are automatically assigned to optionalNamespaces. Considering using only optionalNamespaces') Map<String, RequiredNamespace>? requiredNamespaces,
  9. Map<String, RequiredNamespace>? optionalNamespaces,
  10. Set<String>? featuredWalletIds,
  11. Set<String>? includedWalletIds,
  12. Set<String>? excludedWalletIds,
  13. Future<double> getBalanceFallback()?,
  14. LogLevel logLevel = LogLevel.nothing,
  15. bool disconnectOnDispose = true,
  16. List<ReownAppKitModalWalletInfo> customWallets = const [],
})

Implementation

ReownAppKitModal({
  required BuildContext context,
  IReownAppKit? appKit,
  String? projectId,
  PairingMetadata? metadata,
  bool? enableAnalytics,
  SIWEConfig? siweConfig,
  FeaturesConfig? featuresConfig,
  @Deprecated(
    'requiredNamespaces are automatically assigned to optionalNamespaces. Considering using only optionalNamespaces',
  )
  Map<String, RequiredNamespace>? requiredNamespaces,
  Map<String, RequiredNamespace>? optionalNamespaces,
  Set<String>? featuredWalletIds,
  Set<String>? includedWalletIds,
  Set<String>? excludedWalletIds,
  Future<double> Function()? getBalanceFallback,
  LogLevel logLevel = LogLevel.nothing,
  bool disconnectOnDispose = true,
  List<ReownAppKitModalWalletInfo> customWallets = const [],
}) {
  if (appKit == null) {
    if (projectId == null) {
      throw ReownAppKitModalException(
        'Either a `projectId` and `metadata` must be provided or an already created `appKit` instance. '
        'See https://docs.reown.com/appkit/flutter/core/usage#initialization',
      );
    }
    if (metadata == null) {
      throw ReownAppKitModalException(
        '`metadata:` parameter is required when using `projectId:`. '
        'See https://docs.reown.com/appkit/flutter/core/usage#initialization',
      );
    }
  }

  this.featuresConfig = featuresConfig ?? FeaturesConfig();

  _context = context;
  _getBalance = getBalanceFallback;
  _disconnectOnDispose = disconnectOnDispose;
  _customWallets = customWallets;

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

  _setOptionalNamespaces(
    _buildNamespaces(requiredNamespaces, optionalNamespaces),
  );

  _registerServices(
    analyticsEnabled: enableAnalytics,
    featuredWalletIds: featuredWalletIds,
    includedWalletIds: includedWalletIds,
    excludedWalletIds: excludedWalletIds,
    siweConfig: siweConfig,
  );
}