user3210787
user3210787

Reputation: 157

Flutter - correct way to use and modify packages?

[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!

Upvotes: 2

Views: 1582

Answers (1)

Saeed Fekri
Saeed Fekri

Reputation: 1135

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.sstatic.net/TCepi.png

and add in pubspec.yalm like this:

dependencies:
  flutter:
    sdk: flutter

  your_package:
    path: plugin/

I hope it's useful for you.

Upvotes: 2

Related Questions