Flutter - correct way to use and modify packages?

664

You can add your github project as package to pubspec.yaml like this:

dependencies:
  flutter:
    sdk: flutter

  your_package:
    git:
      url: git://github.com/YOUR_PROJECT

Also you can download any package that you want or even create any local plugin you want and copy in root of your project in folder like plugin:

custom plugin folder in flutter: https://i.stack.imgur.com/TCepi.png

and add in pubspec.yalm like this:

dependencies:
  flutter:
    sdk: flutter

  your_package:
    path: plugin/

I hope it's useful for you.

Share:
664
user3210787
Author by

user3210787

Updated on December 25, 2022

Comments

  • user3210787
    user3210787 over 1 year

    [Disclaimer: I'm not a developer per se, and sentences like "pull request" mean nothing to me, so I'd be grateful for step-by-step explanation (click this in Android Studio, type that in the console)].

    After few weeks of frustration I managed to create my first simple app that looks and does exactly what and how I imagined. To accomplish that I had to use the external package from pub.dev.

    Because it's original functionality wasn't 100% as I expected, I had to do little modifications, but because I wasn't able to modify the imported package directly, I copied the entire code to newly created .dart file and made the modifications there.

    I can imagine this isn't the most elegant solution, but I couldn't figure out another way (I saw some topics on that issue at Stack Overflow, but I simply couldn't understand the 'jargon' and follow the instructions). All I managed to do is to "fork" the package to my own Git, but don't know how to use it in my code, so that I can modify it to my requirements.

    So for any guidance how to use and modify external packages, preferably step-by-step (click this, type that in here), I'll be the most grateful!

  • user3210787
    user3210787 over 3 years
    Thank you, exacty what I needed. One more question: when importing as a local plugin, I then have ti import it using import 'plugin/.....' line in the dart file, correct?
  • Saeed Fekri
    Saeed Fekri over 3 years
    Yes, in fact, the project folder is the root and all addresses are from the root. glad it was useful to you. :)