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

[ Entry point(s) & Flavorising classes ] #17

Open
Gobmichet opened this issue Jan 25, 2024 · 0 comments
Open

[ Entry point(s) & Flavorising classes ] #17

Gobmichet opened this issue Jan 25, 2024 · 0 comments

Comments

@Gobmichet
Copy link

Gobmichet commented Jan 25, 2024

Hi,
Thanks for the job,

1/
i've read many tutorials on the subject including the official flutter doc and i have to admit i'm quite confused with having to create as many entry points as flavors...
That is to say one main.dart per Flavor indeed...

Isn't there a way to have an only entry point ?

I thought that it would work like this :

  • Entry point = main.dart
  • When entering main.dart, test the --flavor param of the executed cmd line
  • switch() on that then load correct params...

what's the point of --flavor then ? can't we just precise the entry point and have the exact same behavior without the whole flavor configuration stuff ??

2/
I already got a config.dart file where i got all my project's URLs in a Config class.

But NO base_url in common :( Since there are 30+ URLs how to correctly Flavorise them ??

is there a way to flavorise whole classes ?
For example, can i just write something like :

FlavorConfig(
    name: "DEVELOP",
    color: Colors.red,
    location: BannerLocation.bottomStart,
    variables: {
        "counter": 0,
         ̶ ̶"̶b̶a̶s̶e̶U̶r̶l̶"̶:̶ ̶"̶h̶t̶t̶p̶s̶:̶/̶/̶w̶w̶w̶.̶e̶x̶a̶m̶p̶l̶e̶.̶c̶o̶m̶"̶,̶
    }
    **config : ConfigDev** // or Config if --flavor prod
);

and then use it in my code like
FlutterConfig.instance.config.urlWanted
with

class Config {
  static const String urlWanted = "https://prod-dummy-ws/api/";
  [...]
}

Would that work ?

3/
Last but not least, how do you launch the different flavors ?
I mean for the moment i created a different config in Android Studio but what is the lib "way" to launch the different flavors ? i can't find any cmd line to launch on the pub.dev lib's page ?
Android ?
iOS ?

I'm quite confused here,
Can u help plz ?

@Gobmichet Gobmichet changed the title [ Flavors & entry point(s) ] [ Entry point(s) & Flavorising classes ] Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant