几天以来,当我从端点加载数据时,我一直收到此错误,发生了异常。 ClientException(在收到完整的标头之前关闭连接)
import 'package:http/http.dart' show Client;
Client client = Client();
Future<Platoons> fetchMeatifyById(String id) async {
final response = await client.get('$_baseApi/platoons/$id');
if (response.statusCode == 200 || response.statusCode == 201) {
return Platoons(json.decode(response.body));
} else {
throw Exception('Failed to load platoon');
}
}