【问题标题】:Why when I include the http package inside pubspec.yaml does my Flutter web project not work?为什么当我在 pubspec.yaml 中包含 http 包时,我的 Flutter Web 项目不起作用?
【发布时间】:2019-11-05 13:01:54
【问题描述】:

我已经使用 Flutter for web 几天了,现在我已经到了需要向 API 发出 HTTP 请求以获取一些数据的地步,但是当我在 @ 中包含 http 包时987654322@ 并运行应用程序,它不起作用,但是当我删除包并重新运行应用程序时,它可以正常工作。

这是我在将http 包包含在pubspec.yaml 中后运行应用程序时收到的错误消息:

Resolving dependencies...
Git error. Command: git fetch
fatal: not a git repository (or any of the parent directories): .git
exit code 69

【问题讨论】:

    标签: flutter-web


    【解决方案1】:

    您无需将其添加到 pubspec,只需将其导入您正在使用的位置即可:

    import 'package:http/http.dart' as http;
    

    【讨论】:

      猜你喜欢
      • 2020-01-19
      • 1970-01-01
      • 2011-05-23
      • 2010-10-23
      • 2018-11-29
      • 2011-10-22
      • 2011-04-19
      • 2020-11-15
      • 2016-08-11
      相关资源
      最近更新 更多