3

I have created a flutter plugin for android and ios and I want to use that plugin in my flutter app locally. I don't want to upload it to pub.dev but to use it locally in my flutter app. I searched a bit and I found that I can use external packages locally but I didn't find anything about a plugin. These are directories under my plugin package all_pdf_tools:

enter image description here

Out of these which directory do I need to move to my flutter app directory and then how should I declare it to use it in my pubspec.yaml and then how can I use my plugin's methods in the flutter app.

Thank you.

1 Answer 1

5

Make sure that your Flutter app and plugin are in sibling folders.

The add a dependency in pubspec.yaml of your Flutter app:

dependencies:
  all_pdf_tools:
    path: ../all_pdf_tools

This tells your Flutter project to look for your plugin at the relative path, rather than in pub or a local git repo.

(If you look in all_pdf_tools/example/pubspec.yaml you'll see this is how the example app refers to its plugin by using path: ../)

Sign up to request clarification or add additional context in comments.

8 Comments

Means I'll have to copy paste this all_pdf_tools directory into my flutter app directory
Do I need these example and test directories?
No - into an adjacent folder - e.g. /projects/my_app and /projects/my_plugin (and you can use a more complicated relative path if you want, too, if they aren't adjacent)
import 'package:all_pdf_tools/all_pdf_tools.dart';
I will give it a try and will update you by tomorrow. Thank you.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.