这可能是由于与您在Flutter中使用的HTTP库或具体的请求方式有关。请确保您在Flutter中使用的HTTP库与您在测试工具中使用的HTTP库相同。
如果您使用的是Dart的内置HTTP库,则可能需要注意以下几点:
dependencies: http: ^0.12.2
import 'package:http/http.dart' as http;
Future fetchData() async { final response = await http.get('https://example.com/api'); if (response.statusCode == 200) { return response.body; } else { throw Exception('Failed to fetch data'); } }
希望这些解决方法对您有所帮助!