Flutter Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source. sdk: flutter 

Posted by

Error:

Resolving dependencies... 
Error on line 32, column 5 of pubspec.yaml: A dependency may only have one source.
   ╷
32 │ ┌     sdk: flutter
33 │ │     webview_flutter: ^4.13.0
34 │ │   # The following adds the Cupertino Icons font to your application.
35 │ │   # Use with the CupertinoIcons class for iOS style icons.
36 │ │     cupertino_icons: ^1.0.8
37 │ └
   ╵
Failed to update packages.

The error means that in your pubspec.yaml file, a dependency is specified incorrectly — each dependency can only have one source, like sdk or a version number, not both at the same time.

Problem Explanation

  • The error on line 32 shows:
sdk: flutter
webview_flutter: ^4.13.0
  • You may have listed multiple sources or incorrectly formatted keys and values under dependencies.
  • For each dependency, you need either:
    • sdk: flutter (for Flutter SDK-related packages)
    • Or a version like webview_flutter: ^4.13.0 (for package version)
  • Never combine them together, and always ensure proper indentation.

Solution:

The dependencies should look like this:

dependencies:
  flutter:
    sdk: flutter
  webview_flutter: ^4.13.0
  cupertino_icons: ^1.0.8
  • Make sure you do not write both sdk: flutter and a version for any single package.
  • Delete any extra lines or duplicate sources for the same dependency so each one is declared properly.

Leave a Reply

Your email address will not be published. Required fields are marked *

0
Would love your thoughts, please comment.x
()
x