'how to add flutter plugin via git to another flutter project?

I want to add one flutter plugin in github as dependency to another flutter project.

i have followed the code https://flutter.dev/docs/development/packages-and-plugins/using-packages#dependencies-on-unpublished-packages and added a ref tag as mentioned here https://dart.dev/tools/pub/dependencies#git-packages

dependencies:
  mypluginname:
    git:
      url: http://mywebsite/myproject.git
      ref: master

i expect to fetch the latest commit of this branch(master), but it fetches first commit.



Solution 1:[1]

Specifying the concrete commit like below helped me:

dependencies:
  mypluginname:
    git:
      url: http://mywebsite/myproject.git
      ref: fad1b1dece2980dab850fc5128ae3c139963c0be

Solution 2:[2]

To complete Tomas' answer. Use path field to point to a specific directory. Example:

dependencies:
  menubar:
    git:
      url: https://github.com/google/flutter-desktop-embedding.git
      path: plugins/menubar
      ref: master

Run this flutter pub get to install it.

Solution 3:[3]

you can

  1. comment out the plugin in pubspec.yaml
  2. run -> flutter packages get
  3. uncomment and repeat step 2)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomas Baran
Solution 2 artronics
Solution 3 David Machara