在Android设备上使用此代码发送POST请求时遇到问题。
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
class NetworkUtil {
// next three lines makes this class a Singleton
static NetworkUtil _instance = new NetworkUtil.internal();
NetworkUtil.internal();
我在http.dart包中使用https进行登录,当我的restful在本地主机和(http协议)中运行时,但是当我将后端api上传到共享主机(https协议)时,一切都很好:
I/flutter (12071): HandshakeException: Handshake error in client (OS Error:
I/flutter (12071): CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:363))
这是我的http请求代码:
final res =
我在发送邮件请求时出现了一个奇怪的错误。
// this map is passed to a function
final Map<String, dynamic> activityData = {
"userId": 1,
"name": activityName.text,
"description": activityDescription.text,
"startAt": activityStartAt.text,
"endsAt": activityEndAt.text,
我使用颤振http包创建了简单的post请求。但是我在发送请求时出错了。
E/flutter ( 9479): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 9479): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, String>'
E/flutter ( 9479): #0
我正在尝试执行对本地服务器的http请求,但我得到了以下错误消息:错误状态:平台不允许不安全的http: HTTP : // mylocalip / auth / login,有人知道如何解决吗?
注意:我还使用了模块化的颤振和mobx
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.22.0-10.0.pre.251, on Microsoft
Windows [versão 10.0.19041.508], locale pt-BR)
[√] A
你好,我这里有个小问题,但我不知道如何解决它,我有一个来自flutter的数据,我想要的是从flutter的post请求中使用node.js查询 //code from flutter app
Future getB(townId) async{
var data;
print(townId);
final response = await http.post("http://xxx.xxx.xx.xx:3000/selectB",body:{
"townid": townId.toString()
});
d
为了向url:发出一个web请求,我尝试遵循这个官方教程。
因此,我在pubspec.yaml中添加了这些行:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
http: 0.11.3+17
json_annotation: ^0.2.3
我有一个函数postList,它从Wordpress生成的json中检索帖子列表。id变量是页码,所以每次我到达底部,它都会添加一个循环进度条,并以卡片的形式加载更多的值(customCard函数)。
_getJsonData(url, page) async {
final response = await http.get("$url?page=$page");
if (response.statusCode == 200) {
// If the call to the server was successful, parse the JSON
r
我创建了一个模型类,并将其转发到put api。但它显示了一个错误
type 'AddressInfo' is not a subtype of type 'String' in type cast
类被正确序列化,我检查了在http请求期间发生的map.This错误的输出。
模型类
@JsonSerializable()
class AddressInfo{
String city;
List<String> operationAreas=new List();
AddressInfo(
this.city,
我正在尝试将json对象发送到api端点。但我得到了以下信息: I / flutter(28184): 200
I / flutter(28184): {"error": "the JSON object must be str, not 'bytes'"} 我尝试过以下几种方法: Future<http.Response> sendPost() async{
var post = {
"profile_id" : "${_profile_id}",
"prof
我试图使用API删除图像的背景。因此,我使用的是http颤振包。但是我得到了<title>400 Bad Request</title>错误。我怎么才能解决这个问题?
这就是我试过的,
removeBackGround(String imagePath) async {
final body = {"image_file": imagePath};
final headers = {"X-API-Key": "e5adebcdc77**************"};
final res