Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

flutter

I keep getting

Running "flutter packages get" in flutter_sportters... Error on line 6, column 5 of pubspec.yaml: A dependency may only have one source.     sdk: flutter     ^^^^^^^^^^^^^ 

When I run my app or Packages Get.

It worked perfectly fine before. Have no idea how to fix this.

like image 281
GI HYUN NAM Avatar asked Mar 25 '18 10:03

GI HYUN NAM


People also ask

What is flutter Pubspec yaml?

Every Flutter project includes a pubspec. yaml file, often referred to as the pubspec. A basic pubspec is generated when you create a new Flutter project. It's located at the top of the project tree and contains metadata about the project that the Dart and Flutter tooling needs to know.

What is a Pubspec yaml file in Dart?

The pubspec. yaml file is transversal to all apps and packages - it is where we add metadata to our project, stipulate the Dart and Flutter SDK constraints, manage the dependencies and also set Flutter-specific configurations.


1 Answers

Consider you are going to use this package "shared_preferences".

You will get this error in pubspec.yaml. If you did like below.

dependencies:  flutter:   sdk: flutter   shared_preferences: v0.4.2 

Indention is important you are accidentally adding shared_preference package below flutter dependency. So the error "A dependency may only have one source"

Correct format below:

dependencies:  flutter:   sdk: flutter   shared_preferences: v0.4.2 #no indention 
like image 183
priwiljay Avatar answered Oct 24 '22 15:10

priwiljay