See also: Flutter's code of conduct
- Linux, Mac OS X, or Windows.
- git (used for source version control).
- An ssh client (used to authenticate with GitHub).
- An IDE such as Android Studio or Visual Studio Code.
flutter_plugin_tools
locally activated.clang-format
(available via brew on macOS, apt on Ubuntu, maybe via llvm on chocolatey for Windows)swiftformat
(available via brew on macOS)
- Ensure all the dependencies described in the previous section are installed.
- Fork
https://github.com/firebase/flutterfire
into your own GitHub account. If you already have a fork, and are now installing a development environment on a new machine, make sure you've updated your fork so that you don't use stale configuration options from long ago. - If you haven't configured your machine with an SSH key that's known to github, then follow GitHub's directions to generate an SSH key.
git clone git@github.com:<your_name_here>/flutterfire.git
git remote add upstream git@github.com:firebase/flutterfire.git
(So that you fetch from the main repository, not your clone, when runninggit fetch
et al.)
FlutterFire uses Melos to manage the project and dependencies.
To install Melos, run the following command from your SSH client:
dart pub global activate melos
Next, at the root of your locally cloned repository bootstrap the projects dependencies:
melos bootstrap
The bootstrap command locally links all dependencies within the project without having to
provide manual dependency_overrides
. This allows all
plugins, examples and tests to build from the local clone project.
You do not need to run
flutter pub get
once bootstrap has been completed.
If you're using fvm you might need to specify the sdk-path:
melos bs --sdk-path=/Users/user/fvm/default/
FlutterFire uses pigeon to generate the MethodChannel
API layer between Dart and the native platforms.
To modify the messages sent with Pigeon (i.e. API code between Dart and native platforms), you can modify the pigeons/messages.dart
file in the corresponding folder and regenerate the code running the below noted melos command.
melos run generate:pigeon
Don't forget to run the formatter on the generated files.
To tests the created interface, you can mock the interface directly with:
TestNAMEHostApi.setup(MockNAMEApp());
Each plugin provides an example app which aims to showcase the main use-cases of each plugin.
To run an example, run the flutter run
command from the example
directory of each plugins main
directory. For example, for Firebase Auth example:
cd packages/firebase_auth/firebase_auth/example
flutter run
Using Melos (installed in step 3), any changes made to the plugins locally will also be reflected within all example applications code automatically.
FlutterFire comprises of a number of tests for each plugin, either end-to-end (e2e) or unit tests.
Unit tests are responsible for ensuring expected behavior whilst developing the plugins Dart code. Unit tests do not
interact with 3rd party Firebase services, and mock where possible. To run unit tests for a specific plugin, run the
flutter test
command from the plugins root directory. For example, Firebase Auth platform interface tests can be run
with the following commands:
cd packages/firebase_auth/firebase_auth_platform_interface
flutter test
E2e tests are those which directly communicate with Firebase, whose results cannot be mocked. These tests run directly from
an example application. To run e2e tests, run the flutter test
(for Android, iOS & macOS) or the flutter drive
(for web)
command from the plugins main example
directory, targeting the entry e2e test file.
Some packages use Firebase Emulator Suite to run tests. To learn more, visit the official documentation.
To start the Firebase Emulator, run these commands:
cd .github/workflows/scripts
melos run firebase:emulator
To run tests, you need to install Melos which is the tool we use to manage this repository. Melos provides a number of commands to quickly run tests against plugins. Install Melos by running the following command from the terminal:
dart pub global activate melos
To run e2e tests, run the following Melos commands from the terminal within the FlutterFire repository:
For the cloud_firestore
plugin:
melos run test:e2e:cloud_firestore
For the firebase_performance
plugin:
melos run test:e2e:firebase_performance
For the rest of the plugins:
melos run test:e2e
To run tests against web environments, please do the following:
- Install
chromedriver
(if you're using a macOS machine for development, you might install via homebrew using the commandbrew install chromedriver
). - Run the following command from the terminal:
chromedriver --port=4444
Once that process is running successfully, please run the web tests running as a release build:
For the cloud_firestore
plugin:
melos run test:e2e:web:cloud_firestore
For the firebase_performance
plugin:
melos run test:e2e:web:firebase_performance
For the rest of the plugins:
melos run test:e2e:web
A full list of all commands can be found within the melos.yaml
file.
We gladly accept contributions via GitHub pull requests.
Please peruse the Flutter style guide and design principles before working on anything non-trivial. These guidelines are intended to keep the code consistent and avoid common pitfalls.
To start working on a patch:
git fetch upstream
git checkout upstream/main -b <name_of_your_branch>
- Hack away!
Once you have made your changes, ensure that it passes the internal analyzer & formatting checks. The following commands can be run locally to highlight any issues before committing your code:
# Run the analyze check
melos analyze-ci
# Format code
melos format-ci
Assuming all is successful, commit and push your code:
git commit -a -m "<your informative commit message>"
git push origin <name_of_your_branch>
To send us a pull request:
git pull-request
(if you are using Hub) or go tohttps://github.com/firebase/flutterfire
and click the "Compare & pull request" button
Please make sure all your check-ins have detailed commit messages explaining the patch.
When naming the title of your pull request, please follow the Conventional Commits guide. For example, for a fix to the Firebase Auth plugin:
fix(firebase_auth): fixed a bug!
Plugins tests are run automatically on contributions using GitHub Actions. Depending on your code contributions, various tests will be run against your updated code automatically.
Once you've gotten an LGTM from a project maintainer and once your PR has received the green light from all our automated testing, wait for one the package maintainers to merge the pull request.
You must complete the Contributor License Agreement. You can do this online, and it only takes a minute. If you've never submitted code before, you must add your (or your organization's) name and contact info to the AUTHORS file.
If you create a new file, do not forget to add the license header. You can use
addlicense
to add the license to all
necessary files.
To install addlicense
, run:
go install github.com/google/addlicense@latest
Do not forget to add $HOME/go/bin
to your PATH
. If you are using Bash on
Linux or macOS, you need to add export PATH="$HOME/go/bin:$PATH"
to your
.bash_profile
.
To add the license header to all files, run from the root of the repository:
melos run add-license-header
This command uses addlicense
with all necessary flags.
Newly opened PRs first go through initial triage which results in one of:
- Merging the PR - if the PR can be quickly reviewed and looks good.
- Closing the PR - if the PR maintainer decides that the PR should not be merged.
- Moving the PR to the backlog - if the review requires non trivial effort and the issue isn't a priority; in this case the maintainer will:
- Make sure that the PR has an associated issue labeled with "plugin".
- Add the "backlog" label to the issue.
- Leave a comment on the PR explaining that the review is not trivial and that the issue will be looked at according to priority order.
- Starting a non trivial review - if the review requires non trivial effort and the issue is a priority; in this case the maintainer will:
- Add the "in review" label to the issue.
- Self assign the PR.
We push releases manually, using Melos to take care of the hard work.
Changelogs and version updates are automatically updated by a project maintainer (via Melos). The new version is automatically generated via the commit types and changelogs via the commit messages.
Some things to keep in mind before publishing the release:
- Has CI ran on the main commit and gone green? Even if CI shows as green on the PR it's still possible for it to fail on merge, for multiple reasons. There may have been some bug in the merge that introduced new failures. CI runs on PRs as it's configured on their branch state, and not on tip of tree. CI on PRs also only runs tests for packages that it detects have been directly changed, vs running on every single package on main.
- Publishing is forever. Hopefully any bugs or breaking in changes in this PR have already been caught in PR review, but now's a second chance to revert before anything goes live.
- "Don't deploy on a Friday." Consider carefully whether or not it's worth immediately publishing an update before a stretch of time where you're going to be unavailable. There may be bugs with the release or questions about it from people that immediately adopt it, and uncovering and resolving those support issues will take more time if you're unavailable.
- Switch to
main
branch locally. - Run
git pull origin main
. - Run
git pull --tags
to make sure all tags are fetched. - Create new branch with the signature "release/[year]-[month]-[day]".
- Push your branch to git running
git push origin [RELEASE BRANCH NAME]
. - Run
melos version
to automatically version packages and update Changelogs. - Run
melos publish
to dry run and confirm all packages are publishable. - Run
melos bom [optional-version]
to update theVERSIONS.md
andscripts/versions.json
files. - Run
git push origin [RELEASE BRANCH NAME]
& open pull request for review on GitHub. - After successful review and merge of the pull request, switch to
main
branch locally, & rungit pull origin main
. - Run
melos publish --no-dry-run
to now publish to Pub.dev. - Run
git push --tags
to push tags to repository. - Ping @kevinthecheung to get the changelog in Firebase releases.
- Switch to
main
branch locally. - Run
git pull origin main
. - Run
git pull --tags
to make sure all tags are fetched. - Create new branch with the signature "release/[year]-[month]-[day]-BoM".
- Run
melos bom [optional-version]
to update theVERSIONS.md
andscripts/versions.json
files. - Push your branch to git running
git push origin [RELEASE BRANCH NAME]
. - After successful review and merge of the pull request, switch to
main
branch locally, & rungit pull origin main
. - Run
git push --tags
to push tags to repository. - Ping @kevinthecheung to get the changelog in Firebase releases.
Sometimes you may need to 'graduate' a package from a 'dev' or 'beta' (versions tagged like this: 0.10.0-dev.4
) to a stable version. Melos can also be used
to graduate multiple packages using the following steps:
- Switch to
main
branch locally. - Run 'git pull origin main'.
- Run
git fetch --all
to make sure all tags and commits are fetched. - Run
melos version --graduate
to prompt a list of all packages to be graduated (You may also specifically select packages using the scope flag like this:--scope="*firestore*"
) - Run
git push --follow-tags
to push the auto commits and tags to the remote repository. - Run
melos publish
to dry run and confirm all packages are publishable. - Run
melos publish --no-dry-run
to now publish to Pub.dev.
We gladly accept contributions to the SDK documentation. As our docs are also part of this repo, see "Contributing code" above for how to prepare and submit a PR to the repo.
Since we merged the Firebase Flutter plugins documentation into the official Firebase documentation on firebase.google.com, you may notice some new markdown syntax related to the publishing infrastructure Google uses for developer documentation.
Firebase follows the Google developer documentation style guide, similar to the Flutter style guide, which you should read before writing substantial contributions.
We also keep a list of issues related to the documentation.