reachability static method
Reads the answer to EcrMethods.probeReachability.
A payload that cannot be read becomes "not reachable" rather than a throw — the same rule MethodChannelAmwalEcr.probeReachability applies when the host itself breaks. A till that cannot ask has no terminal.
Implementation
static EcrReachability reachability(Object? payload) {
final Map<Object?, Object?>? map = _asMap(payload);
if (map == null) {
return const EcrReachability(
reachable: false,
host: '',
port: 0,
error: 'The host answered a reachability probe with nothing usable',
);
}
final String host = _string(map, EcrReachabilityKeys.host);
final int port = _int(map, EcrReachabilityKeys.port);
final String? errorText = map[EcrReachabilityKeys.error]?.toString();
final String endpoint = _string(map, EcrReachabilityKeys.endpoint);
return EcrReachability(
reachable: _bool(map, EcrReachabilityKeys.reachable),
host: host,
port: port,
error: (errorText == null || errorText.isEmpty) ? null : errorText,
endpoint: endpoint.isEmpty ? null : endpoint,
);
}