[Solved] Error on line 24, column 3 of pubspec.yaml: A package may not list itself as a dependency.

This error I got for url_launcher package.

pubspec.yaml:

Actual issue is I have kept my project name also url_launcher and the dependency I am trying to add was also has the same name “url_launcher”.

name: url_launcher
description: A new Flutter project.
dependencies:
  url_launcher: ^5.5.0
  flutter:
    sdk: flutter 

So renaming your project resolve this issue.

Working code for your reference:

name: url_launcher_demo
description: A new Flutter project.
dependencies:
  url_launcher: ^5.5.0
  flutter:
    sdk: flutter  

Leave a Reply