I have a Flutter web app that uses firebase and I have two firebase projects(dev and prod). I'll like to set up Flavors for this project(just web no mobile).
In mobile, I can use different GoogleService-Info.plist
or google-services.json
files for either flavor but I could not find anyway to do this on the web app as the configuration is done in the index.html
file. Is there any way to do this? Maybe have different HTML files and specify which of them to be bundled while running the app?
Thanks.
flutter build --flavor development. On Android, this determines which product flavor is used during the Gradle build process. On iOS, things can be configured so that a different Xcode scheme is used for each flavor. And as of December 2021, the whole process can be (mostly) automated.
If you want to launch a flutter app with a flavor, you have to use the --flavor NAME parameter in the Flutter CLI. To automatically start the app with a flavor in Android Studio we need to change the build configurations: Find main. dart in the Android Studio top toolbar and select Edit Configurations... .
Yes. Flutter is great for both mobile and web app development as it is highly compatible with current-generation web rendering technologies like HTML, CSS, and JavaScript. Using Flutter, you can easily compile the existing code into a client experience, embed it into the browser, and then deploy it to any web server.
You can use Firebase SDK auto-configuration. By relying on the reserved Hosting URL, you can deploy the same code to multiple Firebase projects.
On each of your Firebase projects, go to Project Overview -> Project settings. See here
Under "Your apps" select your web app. If you haven't, link your web app to a firebase hosting site.
In Firebase SDK snippet, select the automatic option. See here
Replace your current firebase configuration on index.html to:
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="/__/firebase/7.21.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="/__/firebase/7.21.0/firebase-analytics.js"></script>
<!-- Initialize Firebase -->
<script src="/__/firebase/init.js"></script>
That's it, this will allow you to use the same index.html for different flavors.
More Info here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With