我对Flutter
非常陌生,并且一直纠结于以下错误:
package:http/http.dart That library is in a package that is not known.
也许你忘了在你的pubspec.yaml
文件中提到它?
请帮助解决此错误。
发布于 2018-11-25 11:35:45
转到pubspec.yaml
文件,并添加http
依赖项:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
http: any
请记住,缩进必须与'flutter‘或'cupertino_icons’相同
别忘了在你的终端上运行这个命令:
flutter packages get
发布于 2019-01-28 13:51:28
我也有同样的问题。只需在pubspec.yaml
中添加最新的http依赖项
这是完整的代码,
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+1
# 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的最新版本,请单击here
如果你直接从命令行运行app,你也可以这样做:
使用Flutter:
$ flutter packages get
使用pub:
$ pub get
发布于 2019-08-06 01:46:22
我发现,在VS Code中,您可能需要重新启动编辑器才能看到'pub get‘引入的新http模块。您的.dart代码和pubspec.yaml可以完全正确,但仍然会出现编译器/lint错误。
https://stackoverflow.com/questions/53462488
复制相似问题