init method

  1. @override
Future<void> init()
override

Implementation

@override
Future<void> init() async {
  if (!_enabled) return;
  // Configure SDK for each platform

  _walletData = (await explorerService.instance.getCoinbaseWalletObject()) ??
      defaultWalletData;
  final imageId = defaultWalletData.listing.imageId;
  _iconImage = explorerService.instance.getWalletImageUrl(imageId);

  final walletLink = _walletData.listing.mobileLink ?? '';
  final redirect = _metadata.redirect;
  final callback = redirect?.universal ?? redirect?.native ?? '';
  if (callback.isNotEmpty || walletLink.isNotEmpty) {
    try {
      final config = Configuration(
        ios: IOSConfiguration(
          host: Uri.parse(walletLink),
          callback: Uri.parse(callback),
        ),
        android: AndroidConfiguration(
          domain: Uri.parse(callback),
        ),
      );
      await CoinbaseWalletSDK.shared.configure(config);
    } catch (_) {
      // Silent error
    }
  } else {
    _enabled = false;
    throw W3MCoinbaseException('Initialization error');
  }
}