这是我的 pubsepc.yaml 代码
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
rxdart: ^0.27.1
path_provider: ^2.0.2
image_picker: ^0.8.0+3
pendatic: ^1.8.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
To add assets to your application, add an assets section, like this:
assets:
- assets/images/apple-in-hand.jpg
- assets/images/apricots.jpg
- assets/images/asparagus.jpg
我不断收到的错误消息如下
PS C:\Users\Geon-Young.Hong\e_commerce> flutter packages get
Error detected in pubspec.yaml:
Unexpected child "To add assets to your application, add an assets section, like this" found under "flutter".
Please correct the pubspec.yaml file at C:\Users\Geon-Young.Hong\e_commerce\pubspec.yaml
运行 flutter doctor 时没有发现问题
PS C:\Users\Geon-Young.Hong\e_commerce> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.19042.1052], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.57.0)
[√] Connected device (2 available)
这是 flutter & dart 版本信息
Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (2 months ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2
我无法导入 rxdart、image_picker 包。 (在lib之外有一个assets目录) 这可能是与版本相关的问题或其他问题。
有人可以帮我解决这个问题吗?
非常感谢!
答案 0 :(得分:1)
从 To add assets to your application, add an assets section, like this:
中删除 pubspec.yaml
部分
答案 1 :(得分:1)
该错误告诉您有一个意外的孩子,"To add assets to your application, add an assets section, like this:"
该行不应该在那里,将其注释掉或删除它,pub get
应该可以正常运行
答案 2 :(得分:1)
将此代码替换为您的pubsepc.yaml我所有的代码如下。
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
rxdart: ^0.27.1
path_provider: ^2.0.2
image_picker: ^0.8.0+3
pendatic: ^1.8.0
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/apple-in-hand.jpg
- assets/images/apricots.jpg
- assets/images/asparagus.jpg