我创建了一个自定义程序包库。该库具有pubspec.yaml中定义的http包依赖项。
version: 0.0.1
author:
homepage:
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
http: ^0.12.0+4
我将此自定义库导入了另一个项目。当我运行此项目时,显示与http软件包相关的错误:
Compiler message:
Error: Could not resolve the package 'http' in 'package:http/http.dart'.
Error: Could not resolve the package 'http_parser' in 'package:http_parser/http_parser.dart'.
../xxxxx/lib/src/network/base/http_request.dart:4:8: Error: Not found: 'package:http/http.dart'
import 'package:http/http.dart';
如果这个http包仅在自定义库中使用,我不明白为什么需要在项目中导入此包依赖项。
谢谢。
答案 0 :(得分:0)
正如@Eugene所说,解决方案是将 http 依赖项移至dependencies:
部分而不是dev_dependencies:
部分
非常感谢@Eugene