Did you know?
If your Flutter app has multiple flavors, you can put all the Firebase initialization logic in one file and switch based on the appFlavor
.
Note: when you do this, all the Firebase config files are bundled in the final app, which is not ideal.
A better solution is to create three entry points that load the corresponding config file and pass it to the function that performs the actual initialization.
When running, you can use the -t
flag to specify the entry point:
This requires a bit more work but is more secure. 👍
My latest course covers flavors and environments in great depth.
To learn more, check it out here: