createPlatformClient function

Client createPlatformClient(
  1. Duration connectionTimeout, {
  2. bool allowSslError = false,
})

Erstellt einen HTTP-Client für Mobile- und Desktop-Plattformen

Verwendet den nativen Dart IO HttpClient für optimale Performance auf Mobile- und Desktop-Plattformen. Unterstützt:

  • Native Netzwerk-Features
  • Erweiterte SSL/TLS-Konfiguration
  • Proxy-Unterstützung
  • Erweiterte Timeout-Kontrolle

connectionTimeout - Timeout für Verbindungsaufbau allowSslError - Ob SSL-Zertifikatsfehler ignoriert werden sollen

Returns: SecureHttpClientIO für Mobile/Desktop-Plattformen

Implementation

http.Client createPlatformClient(
  Duration connectionTimeout, {
  bool allowSslError = false,
}) {
  return SecureHttpClientIO(
    HttpClient()
      ..connectionTimeout = connectionTimeout
      ..badCertificateCallback = (X509Certificate cert, String host, int port) {
        // SSL-Zertifikatsfehler nur in Development-Modus ignorieren
        return allowSslError;
      },
    allowSslError: allowSslError,
  );
}