【问题标题】:flutter Error: The argument type 'ContentType' can't be assigned to the parameter type 'String'颤振错误:无法将参数类型“ContentType”分配给参数类型“String”
【发布时间】:2020-08-31 00:37:13
【问题描述】:

我在运行我的应用程序时遇到错误:

错误:无法将参数类型“ContentType”分配给 参数类型“字符串”。

谁能帮帮我?

Response res = await dio.post(ocrUrl,data:{"image":base64Image}, options: new Options(contentType:ContentType.parse("application/x-www-form-urlencoded")));

【问题讨论】:

  • 您能否提供更多关于您的代码所在位置的上下文。这将使其他人更容易帮助解决问题。
  • 要基于@FabiandePabian 的请求,将您的代码直接包含在问题中而不是链接到屏幕截图会很有用。屏幕截图中的代码很难复制和粘贴以重现问题,或者(在这种情况下更有可能)粘贴到更正的答案中。复制和粘贴此代码比贡献者从您的屏幕截图中转录要容易得多,而且不容易出错。您介意将其编辑到您的问题中吗?

标签: flutter


【解决方案1】:
ContentType.parse

不返回字符串,但options参数需要字符串。

这样做:

"Content-Type":"application/whatever"

options: Options(contentType: ContentType.whatever)

而不是解析。

【讨论】:

    猜你喜欢
    • 2019-12-29
    • 2021-08-26
    • 2021-11-12
    • 2020-11-15
    • 2020-10-22
    • 2021-12-27
    • 2021-10-10
    • 2021-05-13
    • 1970-01-01
    相关资源
    最近更新 更多