Flutter Flavors(android, iOS, firebase) | Create variations of flutter app with same codebase

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm a software engineer in this video I will Implement flavors in flutter flavors are used to create variation of mobile app that share the same code base but have different configuration today I will use it to configure two different API endpoints and Firebase projects for Dev and Broad environments and let's create a new flutter project and I'll rename it as to do okay so now I will open iOS iOS in or in xcode and once it's open I will go to manage scheme and I have to add one more scheme and I'll name it as Dev and rename the default scheme as Broad and close this window and now go to Runner project Runner and we have to add basically configurations so add debug duplicate and rename it as debug Dash Tab and for do the same for release and profile builds so release Dash Tab and for profile so we will rename it profile Dash Dove and now rename the default uh builds as debug dashboard and release dashboard and profile Dash prod because we have renamed the default scheme as brought earlier now go to uh manage scheme again double tap on prod and we have to just verify that the prod configurations are attached to it and now again go to manage scheme and basically now we have to check for Dev so here you can see the prod schemes are attached so we have to change it for our Dev environment so we will do it release to release the stuff and here debug to debug Dash Dev and here release to release uh step as well so now we have to go for Target render and in the build setting Page search here is bundle identifier and we have to add basically dot Dev for our Dev environment so I'll simply copy this and add in the debug in the debug Dash Dev so this is production so we have to remove from here so uh simply copy here as well and paste here as well so now we have to search for product uh product name and uh here I will change from default render to basically in Dev to do Dash Dev for all configurations uh now for profile configuration I will change it and for release Dodge tab as well but in the production environment we will give the actual name uh for uh which we want to basically uh releases now go to uh info uh page and rename uh the 222 dollar bracket product underscore names product name so now it will uh fetch the associated uh build name basically now I will install uh just to verify so I have I'll install the uh our Dev environment first so the name on the launcher icon should be to do Dash Dev so just simply close it and now you can see it hdf on the device now I will install the production build and you will see uh the only to do name on the launcher I can here it is that's it go to Android app build.gradle file and after build types we have to add flavor dimension and set value as default then add product flavors product flavors and plot and Dev Android no address value type string uh underscore name and its value will be 2 2 2. copy this line and paste in the left part and change name from two two two tab also we have to add application ID so fix and its value will be dot Dev now go to source mean Android manifest and change to do to delete string forward slash application underscore name and that's it now under lip career three files main underscore Dev dot dot mean underscore product Dot and and global dot dot now create Global class global and add one variable static string base URL and set empty now go to main file and remove this main function from here and change this file name from me into my because main function is Norm over here so we go to Dev and add main function here simply import this map and we'll add here the global dot base URL and set variable to the dev Dev base URL and we'll copy this and paste in production as well and we'll change Dev to plot now we have to create a new file launch.json and here we have to add parameter program and we have to provide path here leave slash mean underscore dub which is for our Dev environment and we'll name it here as well as so another parameter argument here we have to provide four values first one dash dash flavors and then flavor name which is Dev and then we have to provide here uh the Target and here the path same path we have to provide here as well so we call we'll copy this and paste over here basically we have currently two environment so here is plot we'll change this to a plot simply copy this paste it over here prod here as well so that's it now we will run the app so let's run in the lab environment and let's see okay so we have to change uh basically we want to see if the base URL is uh changing according to uh to the flavor so we'll simply remove this line and add Global dot base URL So currently we are running Dev environment so here you can see the tab this URL now simply quit and run in spot and if I run it and here you can see it shows Rod now we have to connect Firebase with flippers so for Android we will go to Android app and then under Source we have to create two folders one draw it and the other one is Dev now go to uh Firebase console and open project and go to Project settings and download Google services.json file now go to the other project Dev project basically and download the same file now put a product file in the plot folder and the dev file in the dev folder simply rename that file and and that's it for Android Now for iOS power to open OS Project in xcode and Android create a new group and call it config and under config we have to create two groups prod and Dev so Dev and new group and fraught go to Firebase console and in IOS app we have to download this Google services dot PLS file for both projects so this is for a drug environment and now go to prod and download the same file now we have to copy these two files in the relevant folders so paste it in the prod this one for the production now we can also verify the bundle identifier here so this is for part and this one is for tab now go to Target render and in build faces we have to create a new run script and we have to rename this run script so we can identify later and you have to copy this script and I will provide this URL in the comments as well that's all for this video I hope you like it and if you have any questions you can ask in the comment box thanks
Info
Channel: Musawwir Maqsood
Views: 11,250
Rating: undefined out of 5
Keywords: Flutter flavors, android flavors, ios flavors, flutter flavors in android, flutter flavors in ios, flutter flavor, flutter flavors with firebase
Id: GwAnn1auo8o
Channel Id: undefined
Length: 10min 53sec (653 seconds)
Published: Mon Aug 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.