在Flutter上用Dio发出POST请求

时间:2020-05-15 08:53:44

标签: flutter http-post dio

我正在尝试发出POST请求,我只需要 POST字符串,列表和映射

为此,我从locahost制作了一个API。在网络上运行良好(之前经过测试)

但是当我单击运行该功能时,Dio崩溃,无法发出请求

    doFetch() async {
        Response response;
        var dio = new Dio();

        Map<String, dynamic> data ={
            'textOnly': "Prueba de Texto",
            'arrayOnly': ['Alexis', 'Patrcia'],
            'objectOnly': {"nombre": "Guadalue"},
        };

        Options opciones = Options(contentType:Headers.formUrlEncodedContentType);

        response = await dio.post(
            'https://localhost:3000/basic', 
            data: data,
            options: opciones);
        print(response);
    }

Error trigered by Dio

如您所见,该应用程序正在冻结

App freezing by the error

所以我只想做到这一点,你能帮我吗?

0 个答案:

没有答案