【问题标题】:http: Unable to import http dependency in flutterhttp: 无法在 flutter 中导入 http 依赖
【发布时间】:2023-02-05 11:19:03
【问题描述】:

我在 pubspec.yaml 文件中添加了依赖项:

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  http: ^0.13.5

然后还运行了命令 **flutter packages get **

即使在这之后我也无法在我的 main.dart 文件中导入它的包。

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

已将此行添加到我的 main.dart 文件中,但仍然出现错误并且无法在我的代码中使用 http 方法。

【问题讨论】:

  • stackoverflow.com/help/how-to-ask 包括使您的问题与网站上已有的类似问题不同的任何错误消息、关键 API 或异常情况。
  • 你应该运行flutter pub get

标签: android flutter android-studio dart https


【解决方案1】:

重新启动 IDE 并运行以下命令:

flutter clean
flutter pub get

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 2013-10-24
    • 2021-08-07
    • 1970-01-01
    • 2019-12-12
    相关资源
    最近更新 更多