相关守则:
String _baseUrl = 'localhost:3001/api/v1';
String _path = 'items';
Uri uri = Uri.http(_baseUrl, _path); 错误发生在对Uri.http的调用中。以下是错误:
FormatException (FormatException: Invalid radix-10 number (at character 1)
3001/api/v1
^发布于 2021-05-20 22:08:42
这个错误是误导性的。问题与3001部分无关,相反,Uri.http期望base_url更基本。
将代码更改为该代码解决了以下问题:
String _baseUrl = 'localhost:3001';
String _path = 'api/v1/items';
Uri uri = Uri.http(_baseUrl, _path);注意:如果使用设备(android或ios),请将localhost替换为特定地址,请参见:How to point to localhost:8000 with the Dart http package in Flutter?
https://stackoverflow.com/questions/67628555
复制相似问题