未来的抖动问题<http.Response>

我对返回类型“ Response”有疑问。我真的不知道如何处理这种类型。 我必须转换它吗?我只想在屏幕上显示响应。

有人可以解释这个问题吗?

  var username = 'dslf-config';
  var password = '53259721';
  static String port = "37443";
  String url = 'https://192.168.2.1:' + port;
  //unused.... String parameter = 'Device.DeviceInfo.ModelName';

  var body = """
    <?xml version="1.0" encoding= "UTF-8" ?>
    <soap-env:Envelope soap-enc="http://schemas.xmlsaop.org/soap/encoding/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cwmp="urn:telekom-de.totr64-2-n">
        <soap-env:Body>
            <cwmp:GetParameterValues xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
                <cwmp:ParameterNames soap-env:arrayType="xsd:string[10]">
                    <xsd:string>Device.DeviceInfo.ModelName</xsd:string>
                </cwmp:ParameterNames>
            </cwmp:GetParameterValues>
        </soap-env:Body>
    </soap-env:Envelope>""";

  Future<http.Response> getData2() {
    bool trustSelfSigned = true;
    Map<String,String> headers = {
      "accept": "*/*","Content-Type": "text/xml","SOAPaction":
          "urn:telekom-de:device:TO_InternetGatewayDevice:2#GetParameterValues"
    };

    HttpClient httpClient = new HttpClient()
      ..badCertificateCallback =
          ((X509Certificate cert,String host,int port) => trustSelfSigned);

    httpClient.addCredentials(Uri.parse(url),"theRealm",new HttpClientDigestCredentials(username,password));

    IOClient ioClient = new IOClient(httpClient);

    return ioClient.post(Uri.parse(url),headers: headers,body: body); 
  }

  getData3() async {
    final response = await getData2();
    print(response.body);
    print(response.statusCode);
    print(response.headers);
  }
nb_sky 回答:未来的抖动问题<http.Response>

目前尚不清楚您的问题是什么。如果您希望将响应的正文显示在应用程序中,则可以将其放在Text小部件中,例如Text(response.body)

如果是关于HTTP响应的,那么我建议您阅读有关HTTP请求和响应如何工作的文章。 Flutter中的http.Response类仅解析原始HTTP响应并将其呈现给用户。

本文链接:https://www.f2er.com/3110033.html

大家都在问