AngeloAvv / flutter_flavorizr

A flutter utility to easily create flavors in your flutter application
https://pub.dev/packages/flutter_flavorizr
MIT License
468 stars 85 forks source link

Is there a way to share variables across flavors in pubspec.yaml? #142

Closed kvenn closed 1 year ago

kvenn commented 1 year ago

I have 4 flavors appDev, appProd, app2Dev, app2Prod. appDev and appProd should have the same resValues but different applicationId. app2Dev and app2Prod have everything different.

Is there a way to assign resValues to a variable so I don't need to update both configs each time?

 appDev:
   app:
     name: "my app dev"
   android:
    applicationId: "com.app.dev"
     resValues:
       URL_SCHEME:
         type: "string"
         value: "app"
       CUSTOM_LINK:
         type: "string"
         value: "link.app.com"

  appProd:
   app:
     name: "my app"
   android:
    applicationId: "com.app"
     resValues:
       URL_SCHEME:
         type: "string"
         value: "app"
       CUSTOM_LINK:
         type: "string"
         value: "link.app.com"
emri99 commented 1 year ago

You may use YAML syntax to achieve this, it's not perfect, but still a bit better IMO

.my_custom_variables_arbitrary_key:
  android_dev_arbitratry_key: &android_variables_dev
    my_android_var:
      type: "string"
      value: "my-value-for-android"

  ios_dev_arbitratry_key: &ios_variables_dev
    MY_IOS_VAR:
      value: "my-value-for-ios"

flavorizr:
  flavors:
    development:
      app: 
        ...
      android:
        ...
        resValues: *android_variables_dev
      ios:
        ...
        variables: *ios_variables_dev

I think this can also be written like this if you need to add more variables (but I haven't test it ;) )

flavorizr:
  flavors:
    development:
      app: 
      ios:
        variables:
          <<: *ios_variables_dev
          my_other_var:
            value: "second"