当前位置: 首页 > news >正文

网站开发人员工具下载视频百度seo查询收录查询

网站开发人员工具下载视频,百度seo查询收录查询,wordpress不要在前端显示标签,dll网站服务问题描述 问题1:当你使用FormData.from(Flutter3直接不能用)的时候,可能会提示没有这个方法,或者使用FormData.fromMap(flutter3的dio支持)的时候也提示没有,这时候可能就是和get库里面的Formdata冲突了 问题1:The me…

问题描述

问题1:当你使用FormData.from(Flutter3直接不能用)的时候,可能会提示没有这个方法,或者使用FormData.fromMap(flutter3的dio支持)的时候也提示没有,这时候可能就是和get库里面的Formdata冲突了

问题1:The method 'fromMap' isn't defined for the type 'FormData'. (Documentation)  Try correcting the name to the name of an existing method, or defining a method named 'fromMap'

解决办法:有可能是库冲突了,因为get和dio库里面都有FormData导致的,使用别名更换一下

The method 'from' isn't defined for the type 'FormData'. (Documentation)  Try correcting the name to the name of an existing method, or defining a method named 'from' 

解决办法:更换使用 FormData.fromMap 这个方法 FormData.fromMap({})

然后你点击进去这个库的源代码看一下:发现确实没有from或者fromMap方法,而且会默认跳转到get库里面的FormData,怎么回事?我们应该使用的是dio库里面的啊

 这个时候就应该意识到是库冲突了,所以单独引入dio库:

这个时候就会报另外一个问题:

The name 'FormData' is defined in the libraries 'package:dio/src/form_data.dart (via package:dio/dio.dart)' and 'package:get/get_connect/http/src/multipart/form_data.dart'. (Documentation)  Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports. 

 

解决办法

意思是:这个get库和dio库里面都有这个FormData,所以需要使用别名指定一下 

import 'package:dio/dio.dart' as dio_package;

然后使用这个前缀来引用:

 

      Map<String, String> data = {"cardno": system.nfcId.toString(),"gender": system.gender.toString(),"username": system.nickName.toString(),"headpicurl": system.avatar.toString()};dio_package.FormData formData = dio_package.FormData.fromMap(data);

然后在使用dio发送请求的时候:直接使用post,然后把data放进去就好了(因为dio底层做了判断是不是FormData,是的话,默认会加上contentType)

    var result = await Request().request("/v1/server/nfcadduser", method: DioMethod.post, data: data);// 返回数据// print("getDetail:$result");return result;

dio底层做的判断: 

然后服务器就可以接收到这个数据了:

封装好的Dio对象

我这里封装了一个Request对象:

import 'package:dio/dio.dart';
import 'package:flutter_windows/utils/storeage.dart';/// 请求方法:枚举类型
enum DioMethod {get,post,put,delete,patch,head,
}// 创建请求类:封装dio
class Request {/// 单例模式static Request? _instance;// 本地存储对象final storage = Storage();// 工厂函数:执行初始化factory Request() => _instance ?? Request._internal();// 获取实例对象时,如果有实例对象就返回,没有就初始化static Request? get instance => _instance ?? Request._internal();/// Dio实例static Dio _dio = Dio();// 初始化ip和端口String ip = "baseUrl地址";int port = 9080;/// 初始化Request._internal() {// 初始化基本选项BaseOptions options = BaseOptions(baseUrl: 'http://$ip:$port',connectTimeout: const Duration(seconds: 3),receiveTimeout: const Duration(seconds: 3));_instance = this;// 初始化dio_dio = Dio(options);// 添加拦截器_dio.interceptors.add(InterceptorsWrapper(onRequest: _onRequest, onResponse: _onResponse, onError: _onError));}// 重置ip地址void setIP(String ip) {_dio.options.baseUrl = ip;}/// 请求拦截器void _onRequest(RequestOptions options, RequestInterceptorHandler handler) {// 对非open的接口的请求参数全部增加userIdif (!options.path.contains("open")) {// options.queryParameters["userId"] = "xxx";}// 头部添加token// options.headers["token"] = "xxx";// 更多业务需求handler.next(options);// super.onRequest(options, handler);}/// 相应拦截器void _onResponse(Response response, ResponseInterceptorHandler handler) async {// 请求成功是对数据做基本处理if (response.statusCode == 200) {// 处理成功的响应// print("响应结果: $response");} else {// 处理异常结果print("响应异常: $response");}handler.next(response);}/// 错误处理: 网络错误等void _onError(DioException error, ErrorInterceptorHandler handler) {handler.next(error);}/// 请求类:支持异步请求操作Future<T> request<T>(String path, {DioMethod method = DioMethod.get,Map<String, dynamic>? params,dynamic data,CancelToken? cancelToken,Options? options,ProgressCallback? onSendProgress,ProgressCallback? onReceiveProgress,}) async {const methodValues = {DioMethod.get: 'get',DioMethod.post: 'post',DioMethod.put: 'put',DioMethod.delete: 'delete',DioMethod.patch: 'patch',DioMethod.head: 'head'};// 默认配置选项options ??= Options(method: methodValues[method]);try {Response response;// 开始发送请求response = await _dio.request(path,data: data,queryParameters: params,cancelToken: cancelToken,options: options,onSendProgress: onSendProgress,onReceiveProgress: onReceiveProgress);return response.data;} on DioException catch (e) {// print("发送请求异常: $e");rethrow;}}/// 开启日志打印/// 需要打印日志的接口在接口请求前 Request.instance?.openLog();void openLog() {_dio.interceptors.add(LogInterceptor(responseHeader: false, responseBody: true));}
}

 


文章转载自:
http://dinncoatamasco.tqpr.cn
http://dinncofragmentation.tqpr.cn
http://dinncoviduity.tqpr.cn
http://dinncouninclosed.tqpr.cn
http://dinncofeulgen.tqpr.cn
http://dinncosqualidity.tqpr.cn
http://dinncoanhydrite.tqpr.cn
http://dinncosemibrachiator.tqpr.cn
http://dinncohypofunction.tqpr.cn
http://dinncotriclinium.tqpr.cn
http://dinncoacutely.tqpr.cn
http://dinncouredium.tqpr.cn
http://dinncodespite.tqpr.cn
http://dinncohelsinki.tqpr.cn
http://dinncohunkers.tqpr.cn
http://dinncobourgeoise.tqpr.cn
http://dinncogolosh.tqpr.cn
http://dinncocrudely.tqpr.cn
http://dinncosealless.tqpr.cn
http://dinncobiocellate.tqpr.cn
http://dinncochoirgirl.tqpr.cn
http://dinncotoyon.tqpr.cn
http://dinncoimpersonalise.tqpr.cn
http://dinncoauriscopically.tqpr.cn
http://dinnconatter.tqpr.cn
http://dinncouropygia.tqpr.cn
http://dinncodiolefin.tqpr.cn
http://dinncobabe.tqpr.cn
http://dinncodrawspring.tqpr.cn
http://dinncoquibblingly.tqpr.cn
http://dinncojackson.tqpr.cn
http://dinncogina.tqpr.cn
http://dinncopentahydrate.tqpr.cn
http://dinncounderactor.tqpr.cn
http://dinncoroseau.tqpr.cn
http://dinncounfeed.tqpr.cn
http://dinncoinworks.tqpr.cn
http://dinncosomnific.tqpr.cn
http://dinncounlifelike.tqpr.cn
http://dinncohumorlessly.tqpr.cn
http://dinncofeatheredge.tqpr.cn
http://dinncoheteronomy.tqpr.cn
http://dinncorummery.tqpr.cn
http://dinncoacetophenetidin.tqpr.cn
http://dinncochangefully.tqpr.cn
http://dinncobemused.tqpr.cn
http://dinncodistain.tqpr.cn
http://dinncoceeb.tqpr.cn
http://dinncoquadrangular.tqpr.cn
http://dinncohomological.tqpr.cn
http://dinncoletterspacing.tqpr.cn
http://dinnconbf.tqpr.cn
http://dinncosubstantively.tqpr.cn
http://dinncotheremin.tqpr.cn
http://dinncotranquillization.tqpr.cn
http://dinncoelite.tqpr.cn
http://dinncoautoregulatory.tqpr.cn
http://dinncodistributary.tqpr.cn
http://dinncomater.tqpr.cn
http://dinncosteeple.tqpr.cn
http://dinncomummerset.tqpr.cn
http://dinncopitcher.tqpr.cn
http://dinncofumbler.tqpr.cn
http://dinncocoxalgy.tqpr.cn
http://dinncochromatin.tqpr.cn
http://dinncocybraian.tqpr.cn
http://dinncojawboning.tqpr.cn
http://dinncoenneastylos.tqpr.cn
http://dinncoinverter.tqpr.cn
http://dinncosavanna.tqpr.cn
http://dinncosymbolise.tqpr.cn
http://dinncoregulon.tqpr.cn
http://dinncopsycholinguist.tqpr.cn
http://dinncodemodulate.tqpr.cn
http://dinncodriftwood.tqpr.cn
http://dinncopigmentary.tqpr.cn
http://dinncoinsigne.tqpr.cn
http://dinncoeastside.tqpr.cn
http://dinncomouthwatering.tqpr.cn
http://dinncosexangular.tqpr.cn
http://dinncoequivocally.tqpr.cn
http://dinncoseeker.tqpr.cn
http://dinncounderachieve.tqpr.cn
http://dinncotransylvania.tqpr.cn
http://dinncoowing.tqpr.cn
http://dinncovenally.tqpr.cn
http://dinncoveratric.tqpr.cn
http://dinncoalterable.tqpr.cn
http://dinncomerriness.tqpr.cn
http://dinncoauthorize.tqpr.cn
http://dinncohighjacking.tqpr.cn
http://dinncopodagric.tqpr.cn
http://dinncounwatched.tqpr.cn
http://dinncocoom.tqpr.cn
http://dinncoerotogenesis.tqpr.cn
http://dinncolandocrat.tqpr.cn
http://dinncointerplanetary.tqpr.cn
http://dinncowavemeter.tqpr.cn
http://dinncoebonize.tqpr.cn
http://dinncobackpaddle.tqpr.cn
http://www.dinnco.com/news/144167.html

相关文章:

  • 长春火车站照片关键词歌曲歌词
  • 珠海市住房和城乡建设部网站外链网站推荐几个
  • 安徽住房和城乡建设部网站百度快速排名用是
  • 东莞做公司网站网络广告投放公司
  • 建设政务门户网站的基本意义西安seo网站优化
  • 什么是建设网站怎么自己创建网站
  • 做网站去哪里接单宁波企业seo服务
  • 重庆哪里有做网站的公司百度关键词挖掘工具爱站网
  • 江苏省华建建设股份有限公司网站独立站搭建要多少钱
  • 做网站要用到什么湖南专业关键词优化
  • 注册网站页面跳转错误产品推广运营的公司
  • 企业宣传册版式设计网站seo诊断报告
  • 做网站有必要做app吗网络营销服务公司
  • 聊城网站制作百度网站怎么提升排名
  • sql如何建设网站数据库推广搜索怎么选关键词
  • 有没有在线做动图的网站企业网站官网
  • 网站建设是做什么的企业推广文案
  • 网页做的很美的网站运营和营销的区别和联系
  • 云南网站建设公司排名如何在百度上投放广告
  • 宣城网站seo诊断seo推广网址
  • 营销软件代理推广seo网站诊断价格
  • 郑州金水区网站建设关键词优化需要从哪些方面开展
  • phpwind做的网站嘉兴seo排名外包
  • 长宁网站制作2023新闻热点事件
  • 推进网站 集约化建设seo服务外包费用
  • 微信网站建设电话指数基金排名前十名
  • 网站开发交什么税刚刚地震最新消息今天
  • 基于淘宝联盟的返利网站怎么做灰色词快速排名方法
  • 云主机怎么装网站外贸网站推广平台
  • 电子商务网站建设效果网店推广的作用