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

Flutter targets customization #120

Closed mirland closed 2 years ago

mirland commented 2 years ago

Right now the library is hardcoding the ios flutter targets as 'FLUTTER_TARGET': Variable(value: 'lib/main_$_flavorName.dart'),. However, in some cases you don't want to change the target, you just want to define the project metadata (bundle id and that stuff)

So, what I'm proposing is do that feature optional.

For example, im my case I'm using these instructions:

  instructions:
    - assets:download
    - assets:extract
    - android:buildGradle
    - ios:xcconfig
    - ios:buildTargets
    - ios:schema
    - ios:plist
    - assets:clean

As you can see, I'm not creating custom targets. However, ios:xcconfig is defining the targets for me.

Propose: Add a global property to use custom targets or not:

flavorizr:
  create_flutter_targets: false
AngeloAvv commented 2 years ago

Hey @mirland . To achieve what you want you can simply add a variable in the flavorizr configuration. For instance:

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

      android:
        applicationId: "com.example.apple"

      ios:
        bundleId: "com.example.apple"
        variables:
          FLUTTER_TARGET:
            value: "lib/main.dart"

    banana:
      app:
        name: "Banana App"

      android:
        applicationId: "com.example.banana"

      ios:
        bundleId: "com.example.banana"
        variables:
          FLUTTER_TARGET:
            value: "lib/main.dart"
mirland commented 2 years ago

Cool, thanks!