fromResolved static method

ResolveProfile fromResolved(
  1. Map<String, dynamic>? resolved
)

Normalize a raw GET /sdk/resolve response body into a per-platform view. Pure (no I/O) so it is directly unit-testable. Mirrors resolveProfile() in the Node src/commands/resolve.js.

Implementation

static ResolveProfile fromResolved(Map<String, dynamic>? resolved) {
  final p = _m(resolved?['parameters']);
  final iosUrl = _norm(resolved?['iosUrl']);
  final androidUrl = _norm(resolved?['androidUrl']);
  final desktopUrl = _norm(resolved?['fallbackUrl']);

  final attribution = <String, String>{};
  for (final k in attributionParamKeys) {
    final v = _norm(p[k]);
    if (v != null) attribution[k] = v;
  }

  return ResolveProfile(
    slug: _norm(resolved?['slug']),
    type: _norm(resolved?['type']),
    deepLink: _norm(p['deepLink']),
    forceRedirect: _norm(p['forceRedirect']) == '1',
    ios: PlatformResolution(
      destination: iosUrl,
      app: _norm(p['iosBundleId']),
      scheme: _norm(p['iosCustomScheme']),
      minVersion: _norm(p['iosMinimumVersion']),
    ),
    ipad: PlatformResolution(
      // iPad falls back to the phone iOS route unless an iPad-specific one was set.
      destination: _norm(p['iosIpadFallbackUrl']) ?? iosUrl,
      app: _norm(p['iosIpadBundleId']) ?? _norm(p['iosBundleId']),
    ),
    android: PlatformResolution(
      destination: androidUrl,
      app: _norm(p['androidPackageName']),
      minVersion: _norm(p['androidMinVersion']),
    ),
    desktop: PlatformResolution(destination: desktopUrl),
    attribution: attribution,
  );
}