我正在学习Dart,但我发现了一个问题:
我想从其GitHub存储库添加widget.dart包作为我的项目的依赖项.但是在pub.dartlang.org中有一个非常旧的版本,它需要过时的Web UI.有谁知道,如何从GitHub存储库获取pub(并将其安装为pub.dartlang.org中的那个)?
我在Windows和Dart编辑器上使用GitHub.
更新:我尝试将其添加到依赖项中并以经典方式运行"pub get":
dependencies: widget: git: git@github.com:dart-lang/widget.dart.git
但它返回此错误:
--- 30.1.2014 15:35:27 Running pub get ... --- Pub get failed, [1] Resolving dependencies... Cannot get widget from Git (git@github.com: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.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. **
Günter Zöchb.. 8
在pubspec.yaml
like中添加依赖项
dependencies: widget: git: git@github.com:dart-lang/widget.dart.git
如果你pubspec.yaml
在DartEditor中打开文件,你会得到一个很好的助手
点击 Add...
输入包名称:'widget'
更改查找Source
从hosted
到git
设置Git ref:
为git@github.com:dart-lang/widget.dart.git
您可以pubspec.yaml
在小部件的GitHub存储库中的文件中查找依赖项名称name: widget
您可以从GitHub存储库中复制git路径SSH clone URL
(在"Download ZIP"按钮上方)
编辑
要完成这项工作,您需要在本地系统上安装git命令行客户端.
您可以手动下载存储库
git clone git@github.com:dart-lang/widget.dart.git
并添加以下依赖项
dependencies: widget: git: ../widget.dart # path: ../widget.dart # would work too
或者,您可以从GitHub下载存储库(以ZIP格式下载)将其解压缩到本地驱动器并使用path:
依赖项
dependencies: widget: path: ../widget.dart
如果您将ZIP解压缩到包的兄弟文件夹中.
另见https://www.dartlang.org/tools/pub/dependencies#git-packages
在pubspec.yaml
like中添加依赖项
dependencies: widget: git: git@github.com:dart-lang/widget.dart.git
如果你pubspec.yaml
在DartEditor中打开文件,你会得到一个很好的助手
点击 Add...
输入包名称:'widget'
更改查找Source
从hosted
到git
设置Git ref:
为git@github.com:dart-lang/widget.dart.git
您可以pubspec.yaml
在小部件的GitHub存储库中的文件中查找依赖项名称name: widget
您可以从GitHub存储库中复制git路径SSH clone URL
(在"Download ZIP"按钮上方)
编辑
要完成这项工作,您需要在本地系统上安装git命令行客户端.
您可以手动下载存储库
git clone git@github.com:dart-lang/widget.dart.git
并添加以下依赖项
dependencies: widget: git: ../widget.dart # path: ../widget.dart # would work too
或者,您可以从GitHub下载存储库(以ZIP格式下载)将其解压缩到本地驱动器并使用path:
依赖项
dependencies: widget: path: ../widget.dart
如果您将ZIP解压缩到包的兄弟文件夹中.
另见https://www.dartlang.org/tools/pub/dependencies#git-packages