简体   繁体   中英

how to modify a dart/flutter package?

I want to use a dart package. Currently its under dependencies in pubspec.yaml . And it works fine. However I need to make a few minor changes to the package. Do I need to import the whole package into my project and make changes there or is there an easier way?

You should clone the package from it's own repository and then just import it using the path instead. For example, if you have let's say, a package called foo: ^1.0.0 and want to modify it:

  1. Go to it's GitHub project and clone it to somewhere in your machine;
  2. Change the path in your pubspec.yaml to:
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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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