Questions tagged [dart-pub]

Pub is a package manager for Dart applications and libraries.

Pub is a package manager for Dart applications and libraries. You can find packages to use in a project or publish packages to the package repository. Pub automatically keeps track of dependencies to other packages and makes sure that the dependencies use the right version of a package.

Basics:

  • Use pub get to get dependencies
  • Use pub upgrade to upgrade a dependency
  • Use pub publish to make your library available for others

Resources:

1128 questions
117
votes
3 answers

What is the caret sign (^) before the dependency version number in Flutter's pubspec.yaml?

In the pubspec.yaml file of my Flutter project there is a caret (^) before the version number of some of the dependencies. dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 english_words: ^3.1.5 What is its purpose? What does it…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
100
votes
16 answers

Flutter Pub: Expected a key while parsing a block mapping. path:

I'm using JSON file and register in Pubspec.ymal but showing error and also when I use an image and register it, the same error also occurs. Maybe there is a formatting mistake in it, but don't know what the problem is.this is the doc I…
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
84
votes
6 answers

How to automatically upgrade Flutter dependencies

My Flutter project has a dependency flutter_dotenv at version ^2.0.1 and I want to automatically upgrade to the new version ^2.0.2. I am running the following command to upgrade it: flutter pub upgrade Reference: Upgrading packages only To update…
Evandro Pomatti
  • 13,341
  • 16
  • 97
  • 165
73
votes
28 answers

Could not find a file named "pubspec.yaml" in

I create a simple Web application but when I want to run it I got this message in "Tools Output": Could not find a file named"pubspec.yaml"in"/home/reza/.pubcache/hosted/pub.dartlang.org/browser-0.10.0+2". How can I fix this problem? I use Ubuntu…
Reza
  • 996
  • 1
  • 9
  • 16
67
votes
1 answer

In Dart and Pub, should I add pubspec.lock to my .gitignore?

Should I add this generated file to my .gitignore so that it doesn't show up in my repository? Should pubspec.lock be included in my repository?
Juniper Belmont
  • 3,296
  • 2
  • 18
  • 28
50
votes
13 answers

FlutterFirebaseCorePlugin.java uses or overrides a deprecated API

Ok so I run my program without importing firebase core, firebase auth and cloud firestore, and my code runs just fine but I register my app with firebase and it still runs fine but as soon as I import Firebase_auth, Firebase_core and…
Fred_Wolfe
  • 658
  • 1
  • 7
  • 18
40
votes
19 answers

Why doesn't build_runner generate files when serializing JSON in dart/flutter

I'm just trying to generate my files with the same command i stored like 3 months ago (i'm not very good with backend and devops) and now it doesn't generate the files anymore. It tells me to use the delete command which i don't remember but even…
morgred
  • 969
  • 5
  • 15
  • 26
37
votes
10 answers

How to format numbers as thousands separators in Dart

I have to format numbers as thousands separators in dart. I have numbers like: 16987 13876 456786 and I want to format them as : 16,987 13,876 4,56,786
Shubhamhackz
  • 7,333
  • 7
  • 50
  • 71
36
votes
3 answers

What's the difference between pub dependencies and dev_dependencies?

What is the difference in dependencies and dev_dependencies in a pubspec.yaml? It seems that when I run pub get the dev_dependencies aren't downloaded.
Austin Cummings
  • 770
  • 1
  • 8
  • 15
33
votes
5 answers

How do I add an Example Project to a Flutter Package?

Is there a way to autogenerate template code for the example map structure in a package? Most packages have a /example folder within the package root that showcases the package functionality. I'm not sure what's the "best" way to create the…
Joel Broström
  • 3,530
  • 1
  • 34
  • 61
33
votes
11 answers

pub global activate command - $HOME/.pub-cache/bin not on path

I was trying to install dart2 recently, but when I try to install pub global activate stagehand, it comes with a warning. Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path. You can fix that by adding this to…
Kevin
  • 477
  • 1
  • 5
  • 13
30
votes
2 answers

Does Dart have import alias?

I found myself written tedious code when importing files into dart files like the following: import '../../constants.dart'; I'm wondering if there is any way to create an alias to specific folder like: import…
Javier Rodriguez
  • 545
  • 1
  • 4
  • 11
25
votes
5 answers

Python and Dart Integration in Flutter Mobile Application

Can i do these two things: Is there any library in dart for Sentiment Analysis? Can I use Python (for Sentiment Analysis) in dart? My main motive for these questions is that I'm working on an application in a flutter and I use sentiment analysis…
Hamza Tanveer
  • 323
  • 1
  • 3
  • 7
24
votes
4 answers

How to use preCachePicture() in flutter_svg

I'm using flutter_svg package to render SVG images in my app, as flutter does not officially supports SVG yet.I'm having a delay of probably few seconds while trying to load SVG images in my app and while looking for the solution I found out that I…
Shubhamhackz
  • 7,333
  • 7
  • 50
  • 71
23
votes
5 answers

How to use my dart packages private and not show on pub dart lang?

I have dart packages that I don't want to publish to pub because of my company agreement. How to use my dart packages for only my company and not show on pub dart lang? I've looked up on this link https://github.com/dart-lang/pub/issues/1050 but…
nhuluseda
  • 637
  • 3
  • 8
  • 19
1
2 3
74 75