AngeloAvv / flutter_flavorizr

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

Flutter: Read variables defined in flavors #232

Closed nikhil-thakkar closed 5 months ago

nikhil-thakkar commented 9 months ago

First of all thank you for this excellent package. This definitively makes life easier for developers.

I have a question about how to read the variables in flutter code which are defined in the flavors. For example

flavors:
  apple:
    app:
      name: "Apple App"

    android:
      applicationId: "com.example.apple"
      resValues:
        variable_one:
          type: "string"
          value: "example variable one"
        variable_two:
          type: "string"
          value: "example variable two"

    ios:
      bundleId: "com.example.apple"
      variables:
        variable_one:
          value: "variable1"
        variable_two:
          target: "Debug"
          value: "variable2"

How would I read the values for "variable_one" and "variable_two" in flutter code assuming the values will reflect as per platform? I couldn't find this answer in the readme file.

AngeloAvv commented 6 months ago

Hey @nikhil-thakkar , if you want to reference them in your flutter code you have to manually define them in the F class file, resValues and iOS variables can only be used on the native side

For future questions please use the Discussion section