Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flavors? #54

Closed
GregorySech opened this issue Oct 20, 2018 · 21 comments · Fixed by #195
Closed

Flavors? #54

GregorySech opened this issue Oct 20, 2018 · 21 comments · Fixed by #195

Comments

@GregorySech
Copy link

It would be nice to have the possibility to use this package also to manage various flavors icons, I guess this might be a breaking change to simply replicate this configuration API.
Another option would be making a new package, some type of flavors helper which uses this package to handle the icon parts.

@GregorySech
Copy link
Author

GregorySech commented Oct 20, 2018

It might not be a breaking change, just adding a "flavors" node with all the flavors icons configuration might do the trick.

@MarkOSullivan94
Copy link
Collaborator

I'm not sure I understand where you're coming from.

I did a bit of research and I've found it's possible to have a debug icon and a release icon for Android: https://stackoverflow.com/questions/22875948/how-to-provide-different-android-app-icons-for-different-gradle-buildtypes/22876224#22876224

Are you wanting something like that? Where you can specify a debug flavor?

Or are you just wanting an option to quickly switch between different flavors of launcher icons?

If you do, this is already possible, you could have your image_path and android / ios icon names all specified for the different flavours and then just comment out the ones which you don't want to use. It'll quickly switch between them for you.

@GregorySech
Copy link
Author

Yes I wanted something like option 1, so that running flutter build --flavor <flavor> would build the requested flavor with a different icon without having to edit the configuration and re-running flutter pub pub run flutter_launcher_icons:main. Although it's not only about debug flavoring.

@MarkOSullivan94
Copy link
Collaborator

Unfortunately unless Flutter cmd line tools support that, you wont be able to run flutter build --flavor <flavor>.

I'll also need to look into how passing cmd line arguments will work as I haven't done that before.

Curious how you would prefer this to be setup within the pubspec.yaml config?

@GregorySech
Copy link
Author

GregorySech commented Oct 20, 2018

The flutter CLI supports it. It's just a pass through to gradle flavours and to iOS schemas.
I'm reproducing these articles about flavoring right now:

  • From salvatoregiordanoo at Medium : article1
  • From Natalie Masse Hooper at Cogitas : article2

I guess a good idea might be, while taking as base the readme example:

dev_dependencies: 
  flutter_test:
    sdk: flutter
    
  flutter_launcher_icons: "^0.6.1"
  
flutter_icons:
  android: true 
  ios: "Example-Icon"
  image_path: "assets/icon/icon.png"
  image_path_android: "assets/icon/icon_android.png"
  image_path_ios: "assets/icon/icon_ios.png"
  adaptive_icon_background: "#FFFAFAFA"
  adaptive_icon_foreground: "assets/icon/icon-foreground.png"
  flavors:
    <flavor-name>:
      android: true 
      ios: "<icon name>"
      image_path: "<path here>"
      image_path_android: "<path here>"
      image_path_ios: "<path here>"
      adaptive_icon_background: "<color here>"
      adaptive_icon_foreground: "<path here>"

by making the flavors node optional older configurations should be compatible with this feature.

@rockneverdies55
Copy link

This would be a killer feature... @MarkOSullivan94 were you be able look into this at all?

@sestegra sestegra mentioned this issue Dec 22, 2018
3 tasks
@sestegra
Copy link
Contributor

sestegra commented Dec 22, 2018

See my pull request.

A sample project is available at following repository:
https://github.com/sestegra/flutter_assets_flavors

@MarkOSullivan94
Copy link
Collaborator

Flavor support is working in the flavor branch for projects which already have flavors setup. I'm hoping to add a separate example app which makes use of flavors before merging that branch into master.

@MarkOSullivan94
Copy link
Collaborator

Related: #130

Will leave this to someone else who has experience with setting up a Flutter project with flavours enabled

@jorgecoca
Copy link
Contributor

I will add a project with flavors set today ;) If so, do you think we could get this merge soon?

@jorgecoca
Copy link
Contributor

I have created #154 to showcase this functionality.

Can someone review the PR? 👀 @MarkOSullivan94 @slightfoot

@MarkOSullivan94
Copy link
Collaborator

MarkOSullivan94 commented Apr 25, 2020

Flavors functionality available for now in the flavors branch thanks to @sestegra for the implementation and @jorgecoca for putting together the example project 🎉

There's currently some merge conflicts preventing it from being merged into master branch right now.

@hhelmric
Copy link

@jorgecoca @sestegra For a bit of clarification, is the intended functionality of this feature to automatically rebuild the app launcher icons every time the app is built?

Or do we still need to manually run this command each time we switch from one flavor to another?
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-${flavor_name}.yaml

@hhelmric
Copy link

@jorgecoca @sestegra For a bit of clarification, is the intended functionality of this feature to automatically rebuild the app launcher icons every time the app is built?

Or do we still need to manually run this command each time we switch from one flavor to another?
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-${flavor_name}.yaml

Ok I take back my question. I had not set everything up correctly so it wasn't working as expected! Once I got everything in the right folders and with the correct names, I was able to run flutter pub get and flutter pub run flutter_launcher_icons:main and it created all of the correct launcher icon files in the android/app/src/${flavor}/res directories. The correct assets are loaded when I switch flavors and I would presume that if I update the icons or graphics, I'll need to run this command again, which should be expected anyways. Thanks!

@w3ggy
Copy link

w3ggy commented Jun 28, 2020

The sample doesn't work in such way.
I run flutter pub run flutter_launcher_icons:main
Then receive Check that your config file flutter_launcher_icons.yaml has a flutter_icons section

The command flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-${flavor_name}.yaml generates for all flavors.

@matthew-carroll
Copy link

Can anyone summarize where this issue stands? Has the functionality been abandoned? Is it blocked on a technical hurdle?

@w3ggy
Copy link

w3ggy commented Jul 14, 2020

I am using it on two projects and everything is fine.
Just a note about confusing way to generate icons for all flavors that you have to run
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-${flavor_name}.yaml that will generate for all flavors.

@lifenautjoe
Copy link

If I get it right, we're supposed to use the branch flavors? Is there any chance that gets merged? Its already a bit behind.

@lifenautjoe
Copy link

I'm trying to figure this out but the examples/flavor just contains 3 config .yaml files. What is supposed to be run to generate the flavored assets?

@MarkOSullivan94
Copy link
Collaborator

MarkOSullivan94 commented Aug 23, 2020

@matthew-carroll @lifenautjoe it currently works in the flavors branch and I've also spent time trying to fix the merge conflicts between the flavors branch and master branch in the develop branch so it can be merged into master

Just want to do some more testing before merging

@lifenautjoe in the example flavors project you can run any of the following commands which will work:

flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-production.yaml

OR 

flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-development.yaml

OR 

flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-integration.yaml

For every single flavor you have within your project, you should have a yaml config file for it, in the example project there's 3 flavors:

  • production
  • integration
  • development

@gazialankus
Copy link

FWIW, just running this is enough to handle all flavors: flutter pub run flutter_launcher_icons

In case you are wondering why it won't work for you, you may have used an underscore instead of a dash before your flavor name. So flutter_launcher_icons-production.yaml is good but flutter_launcher_icons_production.yaml is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants