Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing 3rd party Plugins in Flutter

I want to edit a plugin to fit into my App. I just did that by CTRL+clicking on the plugin import code in flutter and editing the desired .dart file.

Now I wonder, if this could be overwritten in the future.

The path (where I edited the dart file) is:

flutter > .pub-cache > hosted > pub.dartlang.org > PLUGIN NAME > lib > templates > FILENAME.dart

Was this the right way to edit the plugin? Or where should I edit the .dart file?

Thanks for help!

like image 229
Daniel Avatar asked Apr 28 '20 16:04

Daniel


1 Answers

I would advise you to firstly check the license of the package you are editing to see if you are legally allowed to change it. Nevertheless, lets imagine you are and you want to go on.

If you edit a plugin like that, you are just editing your cached version of that plugin. This changes only persist as long as the cache is not updated.

However, if you want your changes to be persistent, you should fork the Github repository and edit the files there. Once you have edited the files in Github you can import them to your project, knowing that they won't be changed unexpectedly.

To import your new forked repository from Github, you go to the pubspec.yaml file and then import it like this:

my_forked_package:
  git:
    url: git://github.com/'YOUR_USERNAME'/my_forked_package.git

Similarly, you can just download the Github repository as a Zip, unZip it wherever you want (not in the project folder) and then import the package like this:

my_forked_package:
  path: 'path_to_package_folder'

I hope this helps you further develop your app!

like image 160
Francisco Javier Snchez Avatar answered Nov 08 '22 11:11

Francisco Javier Snchez