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

Support flavors on web #59388

Closed
provokateurin opened this issue Jun 13, 2020 · 11 comments
Closed

Support flavors on web #59388

provokateurin opened this issue Jun 13, 2020 · 11 comments
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@provokateurin
Copy link

Use case

I have two apps that are basically the same modular app with different features loaded. Currently I have to separate apps that import the same package which handles all the modular things. I figured out that flavors would be perfect to make it simpler, but flavors don't work on web.

Proposal

Flavors should be implemented for web. I know this is harder than on Android or iOS, because the web has no concept of flavors, but still this feature is needed to by developers that use flavors on Android and iOS and want to expand to web.

@TahaTesser
Copy link
Member

Hi @jld3103
Can you explain how it could be implemented on web since there is no concept of flavors in web?

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jun 15, 2020
@provokateurin
Copy link
Author

My only idea was to create separate icons and manifests and use a single index.html file which loads a dynamically generated javascript file which contains the selected flavor. This flavor also needs to be acessible in the dart code. It could use a js interface for that.

I'm not sure if that's a possible solution, but it feels a bit to hacky.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 15, 2020
@TahaTesser
Copy link
Member

TahaTesser commented Jun 15, 2020

@jld3103
I am not sure this could be done, since Flutter doesn't maintain flavors for platforms

You can better ideas if you ask this one Stackoverflow or somewhere else

Please see https://flutter.dev/community for resources and asking questions like this,
you may also get some help if you post it on Stack Overflow and if you need help with your code, please see https://www.reddit.com/r/flutterhelp/
Closing, as this isn't an issue with Flutter itself. If you disagree, please write in the comments and I will reopen it.
Thank you

@provokateurin
Copy link
Author

I'm not asking for help to implement it, but rather for flutter to support it. If flavors are supported on Android and iOS and developers want to port their app to web it will not go well. I mean without official support I now have to craft something custom for my app.

@TahaTesser TahaTesser reopened this Jun 15, 2020
@TahaTesser TahaTesser added c: proposal A detailed proposal for a change to Flutter tool Affects the "flutter" command-line tool. See also t: labels. platform-web Web applications specifically c: new feature Nothing broken; request for a new capability and removed in triage Presently being triaged by the triage team labels Jun 15, 2020
@jonahwilliams
Copy link
Member

We have no plans to support flavors on the web. As an alternative you might consider using dart-defines or different entrypoints.

I have two apps that are basically the same modular app with different features loaded. Currently I have to separate apps that import the same package which handles all the modular things. I figured out that flavors would be perfect to make it simpler, but flavors don't work on web.

Its not really clear why you need flavors for this. Can you file an issue for the problem you are trying to solve, instead of a request for a specific solution

@provokateurin
Copy link
Author

My current workflow contains a script that creates two apps with flutter create and replaces all relevant code. Flavors should make it much simpler, because I'd only need to change flavor and target and everything would work. (I hope this is correct)

@jonahwilliams
Copy link
Member

replaces all relevant code

But what is the relevant code? Are you replacing constants? or...?

@provokateurin
Copy link
Author

Don't have time rn, but here is the script: https://github.com/Viktoriaschule/App/blob/master/scripts/bin/create_app.dart
In can sumerize it later if you want. Sorry for the inconvenience.

@jonahwilliams
Copy link
Member

Don't have time rn, but here is the script:

I don't really have time to figure out your command line tool. Please file a new bug with the problems you want solved rather than the solution you want implemented

@ToddHerron
Copy link

ToddHerron commented Mar 10, 2021

Until Flutter implements flavors for the web builds for directing web builds to different Firebase projects, here is a workaround using deploy targets.

The workaround works like this (see link above for instructions on how to set it up):

iOS and Android

For iOS and Android, to target these firebase instances I use Flutter flavors:

> flutter run --flavor dev
> flutter run --flavor staging
> flutter run --flavor prod

Web (Local web hosting server)

> firebase use dev
> flutter build web
> firebase serve

> firebase use staging
> flutter build web
> firebase serve

> firebase use prod
> flutter build web
> firebase serve

CTL-C to stop the local web server

Web (Firebase web hosting server)

For the Web, to target these firebase instances I use firebase deploy targets:

> firebase use dev
> flutter build web
> firebase deploy

> firebase use staging
> flutter build web
> firebase deploy

> firebase use prod
> flutter build web
> firebase deploy

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter platform-web Web applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

4 participants