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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With