package in a local folder: Editing the pubspec.yaml dependencies: hello_package: git: url: https://github.com/artpluscodeinc/hello_package.git It can depend in a package in a remote Git repository: The official documentation: https://docs.flutter.dev/packages-and-plugins/using-packages#dependencies-on-unpublished-packages
a specific branch or tag: (and use SSH instead of HTTPS) Editing the pubspec.yaml (cont'd) dependencies: hello_package: git: url: [email protected]:artpluscodeinc/many_packages.git path: packages/hello_package ref: 0.1.0 Can specify the path to a subfolder: (and point to a tag)
The code is lib/src/ is private, but can be exported from the files in lib/: Exporting symbols import 'package:hello_package/hello_package.dart' show CounterWidget; Then we can import it from our app:
be imported separately That's it! + + import 'package:hello_package/widgets.dart' show CounterWidget; import 'package:hello_package/add_numbers.dart' show add_numbers;
on: pull_request: name: Flutter Test jobs: build: name: Run flutter test runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v1 with: java-version: '12.x' - uses: subosito/flutter-action@v2 with: channel: 'stable' - uses: webfactory/[email protected] with: ssh-private-key: | ${{ secrets.SSH_PRIVATE_KEY_FOR_THIS_APP_REPO}} - name: Get dependencies run: flutter pub get - name: Run tests run: flutter test --reporter expanded Use SSH keys if your library is private Setup your Github action Encrypted secrets: https://docs.github.com/en/actions/security-guides/encrypted-secrets Managing deploy keys: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys Create a SSH key pair Add the public key as a deploy secret for your app Add the private key as a secret for your package + + +
it public: Publishing a public package dart pub publish --dry-run dart pub publish Log in to pub.dev with a Google account, and upload it: The official documentation: https://dart.dev/tools/pub/publishing Make sure its LICENSE is permissive (BSD-3) Edit the CHANGELOG.md + + Publishing is forever! You can then transfer it to a verified publisher, if you administer one. + +