简体   繁体   English

如何修改飞镖/颤振 package?

[英]how to modify a dart/flutter package?

I want to use a dart package.我想使用 dart package。 Currently its under dependencies in pubspec.yaml .目前它在pubspec.yaml中的依赖项。 And it works fine.它工作正常。 However I need to make a few minor changes to the package.但是我需要对 package 做一些小的改动。 Do I need to import the whole package into my project and make changes there or is there an easier way?我需要将整个 package 导入我的项目并在那里进行更改还是有更简单的方法?

You should clone the package from it's own repository and then just import it using the path instead.应该从它自己的存储库中克隆 package,然后使用路径导入它。 For example, if you have let's say, a package called foo: ^1.0.0 and want to modify it:例如,假设您有一个名为foo: ^1.0.0的 package 并想要修改它:

  1. Go to it's GitHub project and clone it to somewhere in your machine; Go 到它的 GitHub 项目并将其克隆到您机器中的某个位置;
  2. Change the path in your pubspec.yaml to:pubspec.yaml中的路径更改为:
foo:
 path: [your package path]

Have in mind that if you have the project stored in VC, the reference won't work and thus you should always point to a remote dependency unless it's shipped with your app as well (eg. path: ../dependency ).请记住,如果您将项目存储在 VC 中,则引用将不起作用,因此您应该始终指向远程依赖项,除非它也随您的应用程序一起提供(例如path: ../dependency )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM