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
12
votes
1 answer

How to prevent accidental publishing of a private pub package

When I have a package that I absolutely won't publish to pub.dartlang.org, how can I prevent someone accidentally publishing it?
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
12
votes
1 answer

Dart - How does one dart project import code from another dart project without using pub?

Suppose I have two dart projects Project A contains code that uses web component to create bunch of UI widget (similar to https://github.com/kevmoo/widget.dart) Project B contains my front end code that would reuse the UI widget I created in project…
nobody
  • 2,709
  • 6
  • 35
  • 37
11
votes
2 answers

Flutter local notification with action buttons and image

I want to push this type of notification with a firebase message. Now the time I am using a normal notification with https://pub.dev/packages/flutter_local_notifications this package. But I didn't see there is a way to add an Action button. As well…
Kasun Hasanga
  • 1,626
  • 4
  • 15
  • 35
11
votes
2 answers

How to Use SVG or Vector Drawables in Flutter SDK

I want to use SVG/Vector Graphics in my Flutter Application. is there any library or Dart Package which can be used?
Developine
  • 12,483
  • 8
  • 38
  • 42
11
votes
2 answers

What is the difference between lib/src and /bin in dart?

I know that lib/ is where we put all our library files and /bin is where we put our entrypoint for our command-line app. I know both of them are public lib/ and bin but i'm unable to understand the convention of using lib/src which according to the…
Shubhamhackz
  • 7,333
  • 7
  • 50
  • 71
11
votes
2 answers

Am I required to publish my Dart package to pub.dartlang.org before I use it?

With java/gradle I may depend on mavenCentral and mavenLocal and publish my own libs to mavenLocal. How is this done with Dart? I.e. I have multiple projects that depends on some private libs. As I can see "pub publish" can only publish to the…
Gunnar Eketrapp
  • 2,009
  • 1
  • 19
  • 33
10
votes
3 answers

How to solve this error "('HttpClient Function(SecurityContext)') isn't a valid override of 'HttpOverrides.createHttpClient'"

I use flutter version 2.2.1 File : Main.dart This is message error How to solve this error?
10
votes
1 answer

Why flutter `pub get` change pubspec.lock?

When I execute flutter pub get or pub get, these changes their pubspec.lock sometimes like below. sdks: - dart: ">=2.10.2 <=2.11.0-213.1.beta" + dart: ">=2.10.2 <2.11.0" I thought pub get is nealy equal to CocoaPods command pod install which does…
10
votes
1 answer

Not able to mock singleton class in flutter

I have created a class as singleton making a static method to get the instance of that class but while unit test I am not able to mock that class. Is there any other way in dart to only create a single instance and that can be easily unit tested.
Gagan Garcha
  • 111
  • 1
  • 7
9
votes
5 answers

How to exclude files from pub publish for Dart packages?

Is there any way to exclude certain files or directories from pub publish for dart packages? I am publishing a package that has so many screenshots. I want them to upload on GitHub but not on Pub.Dev. The intention behind this is to reduce the…
Shahzad Akram
  • 4,586
  • 6
  • 32
  • 65
9
votes
1 answer

How do configuration flags in pubspec.yaml work?

I am learning Flutter and Dart. I noticed that thepubspec.yaml file seems to contain more than just dependency versions for third party libraries. For example. # The following section is specific to Flutter. flutter: uses-material-design: true I…
ams
  • 60,316
  • 68
  • 200
  • 288
9
votes
1 answer

How to get pub from GitHub as a dependency

I'm learning Dart, but I found a problem: I want to add the widget.dart package from its GitHub repository as a dependency for my project. But in pub.dartlang.org there is very old version, which requires the obsolete Web UI. Does anyone know, how…
aleskva
  • 1,644
  • 2
  • 21
  • 40
9
votes
1 answer

Dart: pub get vs pub upgrade

According to the pub get docs the main difference between pub get and pub upgrade is: If a lockfile already exists, pub get uses the versions of dependencies locked in it if possible. If a dependency isn’t locked, pub will get the latest version of…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
8
votes
7 answers

Flutter flutter_launcher_icons error: pub finished with exit code 255

I want to create my launcher icon for flutter. My config (pubspec.yaml) looks the following. ... # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons:…
Chris
  • 415
  • 5
  • 19
8
votes
1 answer

How to get dartdoc to include additional documentation?

I would like to understand if there is a way for me to include additional documentation with the API docs that get generated by dartdoc. According to the Package layout conventions there is a getting_started.md file included inside the doc/…
ra9r
  • 4,528
  • 4
  • 42
  • 52
1 2
3
74 75