Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a dart package from github to my project?

Tags:

dart

So I have a dart program and I want to add a dart package from github, not from the normal way of adding packages using the IDE package manager since the github version has the latest code.

What would be the process to do this?


This works for me in the real world.

name: game
description: A sample web application
dependencies:
  browser: any
  three:
    git:
      ref: master
      url: 'git://github.com/threeDart/three.dart.git'
like image 939
Phil Avatar asked Nov 30 '13 04:11

Phil


People also ask

How do I install a dart SDK library?

The Dart SDK libraries are built in and are identified with the special dart: prefix. For external libraries installed by pub, use the package: prefix. Get the import details for the package’s main library: Go to vector_math’s entry on the Package site. Click the Installing tab.

How do I use a package in a DART program?

To use a package, do the following: Create a pubspec (a file named pubspec.yaml that lists package dependencies and includes other metadata, such as a version number). Use pub to get your package’s dependencies. If your Dart code depends on a library in the package, import the library.

What is Dart pub get command?

The dart pub get command installs the packages in your app’s dependencies list. Each package can contain libraries and other assets. Pub works recursively; if an included package has dependencies, those packages are installed as well.

How do I install vector_math in Dart?

The Dart SDK libraries are built in and are identified with the special dart: prefix. For external libraries installed by pub, use the package: prefix. Get the import details for the package’s main library: Go to vector_math’s entry on the Package site. Click the Installing tab. Copy the import line.


1 Answers

You can add a dependency to your pubspec.yaml file which points directly to a git url.

For example this pubspec.yaml file adds a dependency to the kittens package:

name: My Dart program
description: Blah
dependencies:
  kittens:
    git: git://github.com/munificent/kittens.git

For more info see the pubspec.yaml docs.

like image 86
Greg Lowe Avatar answered Sep 21 '22 01:09

Greg Lowe