aleskva aleskva - 4 months ago 28
Dart Question

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 there is very old version, which requires the obsolete Web UI. Does anyone know, how to get the pub from GitHub repository (and install it like the one from the

I'm using GitHub on Windows and Dart Editor.

Update: I tried to add it into a dependency and run 'pub get' in the classic way:


But it returns this error:

--- 30.1.2014 15:35:27 Running pub get ... ---
Pub get failed, [1] Resolving dependencies...
Cannot get widget from Git (
Please ensure Git is correctly installed.
e:\b\build\slave\dart-editor-win-stable\build\dart\sdk\lib\_internal\pub\lib\src\source\git.dart 42 GitSource.downloadToSystemCache.<fn>
dart:isolate _RawReceivePortImpl._handleMessage

This is an unexpected error. Please run

pub --trace 'get'

and include the results in a bug report on

** Warning: Application may fail to run since packages did not get installed.Try running pub get again. **

Answer Source

Add the dependency in pubspec.yaml like

Edit pubspec.yaml in text mode


Use the assistant

if you open the pubspec.yaml file in DartEditor you get a nice assistant

  1. click Add...
  2. Enter name of package: 'widget'
  3. Change the lookup Source from hosted to git
  4. Set Git ref: to

Additional Info:

  • You can look up the dependency name in the file pubspec.yaml in the widget's GitHub repository under name: widget
  • You can copy the git path from the GitHub repository under SSH clone URL (above the 'Download ZIP` button)

To make this work you need to have the git command line client installed on your local system.

You can download the repository manually

git clone

and add the following dependency

    git: ../widget.dart
    # path: ../widget.dart # would work too

Alternatively you can download the repository from GitHub (Download as ZIP) extract it to your local drive and use a path: dependency like

    path: ../widget.dart

provided you extracted the ZIP to a sibling folder of your package.

See also

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download