Home > OS >  Error on line 18, column 5 of pubspec.yaml: A dependency may only have one source
Error on line 18, column 5 of pubspec.yaml: A dependency may only have one source

Time:07-27

I'm doing a flutter bootcamp course. 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.

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/

pubspec.yaml error message in dev_dependencies

CodePudding user response:

As for error message, there was an indentation issue. I think you didn't save the pubspec.yaml file. Copy and paste the full snippet and save it then run flutter pub get or use the extension you've used

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/

CodePudding user response:

You can use the pubspec.yaml given by @yeasin Sheikh.. Also if you unfamiliar with using pubspec. The easiest way to add a package is to run

flutter pub add english_words

in terminal. This will add the latest version of english_words package to your pubspec with proper indentation.

  • Related