flutterwebpre-build-event

In flutter web is there a equivalent for reactjs package.json "prebuild"


We have a single package which is built for different sites, which needs some prebuild steps to be executed before actual build steps.

In flutter android, these steps are executed in "preBuild.dependsOn" (in android/app/build.gradle)

Edit (additional info):

MyFlutterMob/android/app/build.gradle

Following prebuild steps are run :

  def option = System.getenv('APK_FOR')

  setConfig()
  {
         if(option == "DEMO"){
             copy{
                 from "../../DemoAppAsset/AppLogo.png"
                 into "../../assets/images" 
             }
         }
         else if(option == "PROD"){
             copy{
                 from "../../ProdAppAsset/AppLogo.png"
                 into "../../assets/images" 
             }
         }
  }

  preBuild.dependsOn setConfig

Is same possible in flutter web build (Not able to find gradle script for same )


Solution

  • Wrote shall scrip which takes environment name(PROD1/PROD2/UAT/... ) as input and copies the required "images to white label" /"theme colour list files"/"strings list configs" into respective folders before running "flutter build web". Although it restricts all release to happen from linux / maintain equivalent bat file for windows, broadly it works out.