简体   繁体   English

pubspec.yaml 第 18 行第 5 列出错:依赖项可能只有一个源

[英]Error on line 18, column 5 of pubspec.yaml: A dependency may only have one source

I'm doing a flutter bootcamp course.我正在参加 flutter 训练营课程。 The task was to add the english_words dependency but while implementing that I ran into an error in the dev_dependencies as it came from the code stub.任务是添加english_words 依赖项,但是在实现时我在dev_dependencies 中遇到了一个错误,因为它来自代码存根。

How can I fix this error?我该如何解决这个错误?

name: xylophone
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  # Use Audioplayers dependency version 0.17.4

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

  assets:
    - assets/

dev_dependencies 中的 pubspec.yaml 错误消息

As for error message, there was an indentation issue.至于错误消息,存在缩进问题。 I think you didn't save the pubspec.yaml file.我认为您没有保存pubspec.yaml文件。 Copy and paste the full snippet and save it then run flutter pub get or use the extension you've used复制并粘贴完整的代码片段并保存,然后运行flutter pub get或使用您使用的扩展程序

name: xylophone
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  english_words: ^4.0.0
  cupertino_icons: ^0.1.2
  # Use Audioplayers dependency version 0.17.4

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
    - assets/

You can use the pubspec.yaml given by @yeasin Sheikh.. Also if you unfamiliar with using pubspec.您可以使用@yeasin Sheikh 给出的 pubspec.yaml .. 另外,如果您不熟悉使用 pubspec。 The easiest way to add a package is to run添加 package 的最简单方法是运行

flutter pub add english_words

in terminal.在终端。 This will add the latest version of english_words package to your pubspec with proper indentation.这会将最新版本的 english_words package 添加到您的 pubspec 中,并带有适当的缩进。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pubspec.yaml 第 6 行第 5 列的 Flutter 错误:依赖项可能只有一个来源。 sdk:颤动^^^^^^^^^^^^^ - Flutter Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source. sdk: flutter ^^^^^^^^^^^^^ pubspec.yaml 的第 21 行第 5 列错误:依赖项可能只有一个源 - Error on line 21, column 5 of pubspec.yaml: A dependency may only have one source pubspec.yaml 的第 17 行第 5 列错误:依赖项可能只有一个源 - Error on line 17, column 5 of pubspec.yaml: A dependency may only have one source pubspec.yaml 第 13 行第 5 列错误:依赖项可能只有一个来源 - Error on line 13, column 5 of pubspec.yaml: A dependency may only have one source Flutter pubspec.yaml - 从分支添加分叉依赖 - 依赖可能只有一个来源 - Flutter pubspec.yaml - Adding forked dependency from branch - A dependency may only have one source Flutter 资产:pubspec.yaml:一个依赖项可能只有一个来源 - Flutter assets: pubspec.yaml: A dependency may only have one source pubspec.yaml 的第 21 行第 5 列出错 - Error on line 21, column 5 of pubspec.yaml 如何修复“在 pubspec.yaml 中检测到错误:第 74 行第 2 列错误:预期为‘:’。” - How to fix "Error detected in pubspec.yaml: Error on line 74, column 2: Expected ':'." pubspec.yaml 第 40 行第 4 列错误:解析块映射时需要一个键。 资产:^ - Error on line 40, column 4 of pubspec.yaml: Expected a key while parsing a block mapping. assets: ^ pubspec.yaml 第 24 行第 5 列出错:版本约束必须是字符串 - Error on line 24, column 5 of pubspec.yaml: A version constraint must be a string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM