In this guide, we'll walk you through the process of setting up SSH for your Flutter project hosted on Bitbucket, including generating SSH keys, adding them to your Bitbucket account, and adding Bitbucket-hosted packages to your Flutter project.
Open the terminal on your developer's computer.
Run the following command to generate a new RSA 4096-bit SSH key pair:
Replace "" with your own email address.
The terminal will prompt you to choose where to save the SSH key. By default, it's usually saved in /home/yourusername/.ssh/id_rsa
. You can specify a different path if you prefer.
Log in to your Bitbucket account.
Click on your avatar in the top right corner, and select "Settings" from the dropdown menu.
Navigate to "SSH Keys" in the left menu.
Click on "Add SSH Key" or "New key".
Copy the content of the id_rsa.pub
file generated in the previous step (you can view the content using the cat ~/.ssh/id_rsa.pub
command).
Optionally, give your key a label, and click "Add".
In the terminal, use the following command to clone the project:
Replace "username" with your Bitbucket username and "repo" with the name of the repository you want to clone.
After cloning is completed, the project will be downloaded to your local computer, and you can start working on it.
Open the project and edit the pubspec.yaml
file.
Add the Bitbucket-hosted packages to the dependencies
section. For example:
Replace "package_name" with the name of the package and "username" with your Bitbucket username.
Optionally, you can use the ref
parameter to specify a version, branch, commit hash, or tag. For example:
This example assumes you want to use the "main" branch. You can use other references as needed.
After making changes to pubspec.yaml
, run the following command in the terminal to update the packages:
This command will download the newly added Bitbucket packages and resolve dependencies.
You've now set up SSH for your Flutter project hosted on Bitbucket and added Bitbucket-hosted packages to your project. Your developer can start working with the project and use the private packages from Bitbucket in their Flutter app.