What is pub tool? - dart

I was studying basics of Flutter and Dart development and came across package manager called pub. What is it and what is it's importance in Flutter development?

Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter, AngularDart, and general Dart programs.
Some basic command:
Use pub get to get dependencies
Use pub upgrade to upgrade a dependency
Use pub publish to make your library available for others
You can find all packages here.
Also you can develop your own package, find the details on official site.

Pub is a package manager for dart to know more about pub see this: https://www.dartlang.org/tools/pub

Related

How to use old version of Flutter and Dart

I'm a new developer and I'm trying to work with an existing IOS application built with Flutter. Some of the pubspec.yaml files show:
version 1.0.2+1
environment sdk ">=2.3.0 <3.0.0
And then various dependencies of other apps.
If I use the latest version of flutter, the application doesn't build. It needs to be built with flutter v1.0.0. But when I install that specific version, flutter pub get doesn't get the rest of the dependencies.
I'm guessing that I'm doing something wrong, but I don't know what.
Please help!
Thank you,
Thomas

pub get to install non-dart dependancies similar to NPM, pip, etc?

When looking at the pub spec format, i was curious if I can install other packages with pub get. My goal is to either install Ruby or some other tools. Even if i have command line access I could run python scripts or similar to get the code.
How does the dart package manager work in this sense? Would it be simpler to just wrap dart with npm or similar and then do all the installs in NPM and follow it up with pub get?
I am curious what the rest of the community is doing for non-dart dependency injection.
Part of me was thinking the executables flag, but i was not not sure.
There's no support for this.
I have a command line tool called scripts that you can use to run additional commands, but it's not an official Dart tool or anything.
https://pub.dartlang.org/packages/scripts

How list/remove globally installed Dart dependencies?

I try to figure out how to manage pub packages. For example, I have the following pubspec.yaml:
name: app
dependencies:
intl: any
browser: any
polymer: any
transformers:
- polymer
After time I consider to remove intl package. As far as I understand running pub get again automatically remove unused packages (to be more precise it removes links but not actual files). If so how can I list/remove actual packages available globally (on Ubuntu under /home/username/.pub-cache/hosted/pub.dartlang.org/)?
Use the den tool. It's a community-contributed tool that provides various utilities for working with pub packages.
den uninstall thing_i_do_not_need_anymore
Only manually by deleting them using your OS tools. There is no pub ... support for that.
pub ... only works for the current project (current working directory) and it doesn't know if versions are used by other projects on your disk.

How can I test the latest Polymer lib when it requires an older SDK?

I wanted to give the latest Dart Polymer lib a spin, so I updated the pubspec file and ran a pub install. However, the install fails with the following message:
Pub install failed, [1] Resolving dependencies.........
Package polymer requires SDK version >=0.8.1+1 but the current SDK is
0.7.6+4.r28108
Is it somehow possible to use the latest Polymer version via pubspec, or do I need to build the SDK myself from the sources?
https://www.dartlang.org/tools/editor/ has links to the bleeding edge, continuous build DartEditor
https://storage.googleapis.com/dart-editor-archive-continuous/latest/darteditor-win32-32.zip
https://storage.googleapis.com/dart-editor-archive-continuous/latest/darteditor-win32-64.zip
As of today, you should be able to upgrade 0.8.1.2 if you go to Help > About Dart Editor.
It seems pretty common that the libraries update a day or two before the SDK, so normally when I run into this problem I put in the pubspec something like the following until I can update the SDK:
dependencies:
polymer: "< 8.0.0"

How to create libraries for Dart?

How can I create libraries using Dart?
I want to start porting some JavaScript (and other languages) libraries I've created to Dart.
Just put this in your library file (first place):
library mylibraryname;
You can then import this lib with:
import "path/to/mylibraryname.dart";
Other options are available, for example part which acts as include.
For a more in-depth tutorial I recommend you this blog post from Dartwatch.
stagehand is the most simply.
Usage
mkdir fancy_project
cd fancy_project
stagehand package-simple
Stagehand templates
console-full - A command-line application sample.
package-simple - A starting point for Dart libraries or applications.
server-shelf - A web server built using the shelf package.
web-angular - A web app with material design components.
web-simple - A web app that uses only core Dart libraries.
web-stagexl - A starting point for 2D animation and games.
Installation
If you want to use Stagehand on the command line, install it using pub global activate:
pub global activate stagehand

Resources