Search code examples
flutterflutter-dependenciespubspec

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


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


Solution

  • 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/