Flutter Project GitHub SSH Guidance
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.
Generating SSH Keys
Open the terminal on your developer's computer.
Run the following command to generate a new RSA 4096-bit SSH key pair:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Replace "[email protected]" 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.
Adding SSH Key to GitHub
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 thecat ~/.ssh/id_rsa.pub
command).Click "Add SSH key" to save it.
Cloning a Flutter Project from GitHub
In the terminal, use the following command to clone the project:
git clone [email protected]:username/repo.git
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.
Adding GitHub-hosted Packages to Flutter Project
Open the project and edit the
pubspec.yaml
file.Add the GitHub-hosted packages to the
dependencies
section. For example:dependencies: package_name: git: url: [email protected]:username/package_name.git
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:dependencies: package_name: git: url: [email protected]:username/package_name.git ref: main
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:flutter pub get
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.
Last updated