当启动热重装时,会抛出一个错误(FormatException.Unexpected character (at character 1))。Unexpected character (at character 1))

问题描述 投票:0回答:2

我想从一个网站上发送一个请求,该网站的工作地点在 http:/flat.imruz.comapisliders。http:/flat.imruz.comapicategories api代码在浏览器中运行良好。但当我在模拟器上运行时,它抛出了一个错误(FormatException.Unexpected character (at character 1))。Unexpected character (at character 1)).我会在下面附上flutter截图。

enter image description here

enter image description here

enter image description here

enter image description here

json api flutter dart
2个回答
0
投票

检查这篇文章 Flutter FormatException.Unexpected character (at character 1) 意外的字符(字符1处)并首先谷歌然后创建一个线程.并检查该 https:/issue.lifequestions57473788在俄语中,但在最后有一个链接,而不是一个有答案的git中心。


0
投票

你的API端点返回HTML而不是JSON。请确保

  • 端点的URL是有效的。
  • 您的请求是有效的,并且API会正确处理错误。
  • 你加了 'Content-type': 'application/json' 头部。
  • 你被授权访问端点。

0
投票

你在最后生成的url中使用了双斜杠。

取而代之

String _baseUrl = 'http://flat.imruz.com/api/';

以此

String _baseUrl = 'http://flat.imruz.com/api'
© www.soinside.com 2019 - 2024. All rights reserved.