首页 > 解决方案 > 从 flutter app 发布数据时出现此错误。未处理的异常:FormatException:无效的 radix-10 数字(在字符 1)

问题描述

注意:我使用真实设备进行应用预览,笔记本电脑和设备共享相同的 wifi。我已将 localhost 更改为 Ipv4 地址。

这是代码片段:

`var response=await http.post(Uri.https('http://***.***.***.**:10000','/postAd'),
          headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8',  },
  body:jsonEncode(<String,String>{
 "category":currentSelectedValue,
 "title":_serviceTitle.text,
 "description":_description.text,
 "phone":_phone.text, 
  "image":base64Image,
                 }
               )
             );`

我已经在服务器端处理了“/postAd”路由,并用 Postman 对其进行了测试[它工作正常]。

/flutter (31503): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: FormatException: 
Invalid radix-10 number (at character 1)
E/flutter (31503): //***.***.***.**:10000
E/flutter (31503): ^
E/flutter (31503):
E/flutter (31503): #0      int._throwFormatException (dart:core-patch/integers_patch.dart:131:5)
E/flutter (31503): #1      int._parseRadix (dart:core-patch/integers_patch.dart:157:16)

标签: flutterflutter-http

解决方案


推荐阅读