Flutter Project GitHub SSH Guidance
Last updated
Last updated
In this guide, we'll walk you through the process of setting up SSH for your Flutter project hosted on GitHub, including generating SSH keys, adding them to your GitHub account, and adding GitHub-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 GitHub account.
Click on your profile picture in the top right corner, and select "Settings" from the dropdown menu.
Navigate to "SSH and GPG keys" in the left sidebar.
Click on "New SSH key".
Give your key a title, and paste 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).
Click "Add SSH key" to save it.
In the terminal, use the following command to clone the project:
Replace "username" with your GitHub 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 GitHub-hosted packages to the dependencies
section. For example:
Replace "package_name" with the name of the package and "username" with your GitHub 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 GitHub packages and resolve dependencies.
You've now set up SSH for your Flutter project hosted on GitHub and added GitHub-hosted packages to your project. Your developer can start working with the project and use the private packages from GitHub in their Flutter app.