Flutter dependencies 使用远程github 仓库地址下的特定路径

3 min read

可以使用Git的依赖方式来使用远程github仓库地址下的特定路径。

  1. 首先,在pubspec.yaml文件中添加Git依赖:
dependencies:
  my_package:
    git:
      url: https://github.com/my_username/my_package.git
      path: specific/path/to/my_package
  1. url中使用完整的远程github仓库地址,并在path中指定特定路径。

  2. 运行flutter packages get命令,Flutter会从远程Github仓库中下载特定路径下的代码并添加到项目中。

这样就可以使用特定路径下的代码了。注意,如果您的依赖项包括依赖项,请在远程仓库中包含所有必需的依赖项。