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 to get the pub from GitHub repository (and install it like the one from the pub.dartlang.org)?
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:
dependencies:
widget:
git: [email protected]:dart-lang/widget.dart.git
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 ([email protected]:dart-lang/widget.dart.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 http://dartbug.com/new.
** Warning: Application may fail to run since packages did not get installed.Try running pub get again. **
Under your repository name, click Settings. In the "Security" section of the sidebar, click Code security and analysis. Read the message about granting GitHub read-only access to the repository data to enable the dependency graph, then next to "Dependency Graph", click Enable.
The dependency graph is a summary of the manifest and lock files stored in a repository. For each repository, it shows dependencies, that is, the ecosystems and packages it depends on. GitHub Enterprise Server does not calculate information about dependents, the repositories and packages that depend on a repository.
Add the dependency in pubspec.yaml
like
dependencies:
widget:
git: [email protected]:dart-lang/widget.dart.git
if you open the pubspec.yaml
file in DartEditor you get a nice assistant
Add...
Source
from hosted
to git
Git ref:
to [email protected]:dart-lang/widget.dart.git
pubspec.yaml
in the widget's GitHub repository under name: widget
SSH clone URL
(above the 'Download ZIP` button)EDIT
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 [email protected]:dart-lang/widget.dart.git
and add the following dependency
dependencies:
widget:
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
dependencies:
widget:
path: ../widget.dart
provided you extracted the ZIP to a sibling folder of your package.
See also https://www.dartlang.org/tools/pub/dependencies#git-packages
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With