![]() Setting Up Deploy Targets for the Web Configuring Your Flutter Project for the Webįlutter for the Web is now on the Flutter stable channel. Often readers have provided very useful solutions to new and common problems. Build flavors in Flutter (Android and iOS) with different Firebase projects per flavor As software platforms often change, if you run into problems with these instructions, please look at the comments on the article.See the following for implementation of Flutter Flavors: Setting Up Flutter Flavors for iOS and Android You have set up your firebase public build target folder to build/web for web hosting.You have already set up your Firebase instances and are comfortable navigating around the Firebase Console.Using This Solution iOS and Androidįor iOS and Android, to target these firebase instances I use Flutter flavors: > flutter run -flavor devįor the Web, to target these firebase instances I use firebase deploy targets: > firebase use devĬTL-C to stop the local web server Web (Firebase web hosting server) ConclusionĪs we have seen, we can use the new FlutterFire CLI to configure our Firebase project with just one command.Īnd if we want to add flavors to the mix, Very Good CLI makes our life easier.In this example, I have three firebase instances (aka "firebase projects") called dev, staging, and prod. In particular, see this comment from this open issue in the Flutterfire client. Sweet, isn't it? □ Note about using Firebase Analytics & CrashlyticsĬertain Firebase services still require some platform-specific configuration to work correctly. main_development.dart import 'package:firebase_core/firebase_core.dart' import 'package:flutter/material.dart' import 'package:my_test_app_flavors/app/view/app.dart' import 'package:my_test_app_flavors/firebase_options_dev.dart' Future main () async Īnd once this is done, we can choose a flavor and run the app on iOS, Android, or web: VS Code launch flavors For consistency, we could name the Firebase projects like so:Īnd then, we can use the FlutterFire CLI generate the correct Dart initialization file for each Flutter flavor, with this command: How to add Firebase to a Flutter app with FlutterFire CLIīut this time, we have to create one Firebase project for each Flutter flavor.Well, we can use the FlutterFire CLI tool to generate correct Firebase configuration for our project, as I have explained in my previous article: Very Good CLI helps us with the Flutter side of things. □ Setting up multiple Firebase environments dartĪlternatively, we can choose the flavor directly from VSCode, as Very Good CLI has already generated multiple launch configurations for us: VS Code launch flavorsīut the best part is that the Xcode and Android projects are already configured to run with multiple flavors, meaning that we don't have to mess about with Xcode schemes or gradle files. dart # Run production flutter run - flavor production - target lib / main_production. dart # Run staging flutter run - flavor staging - target lib / main_staging. ![]() ![]() # Run development flutter run - flavor development - target lib / main_development. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |