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

Use constants to control whether to inject #191

Closed
windrunner414 opened this issue Apr 7, 2021 · 2 comments
Closed

Use constants to control whether to inject #191

windrunner414 opened this issue Apr 7, 2021 · 2 comments

Comments

@windrunner414
Copy link

I don't want to inject a dev config in prod env.Now the code like below:

@dev
class DevConfig {}
@prod
class ProdConfig{}
$initGetIt(getIt,environment:prod);

but the DevConfig still be injected, so dart will not remove it from the compiled app.I want to use a constant to control whether it is injected.generated code like this

if (injectDev) singleton<Config>(DevConfig(), registerFor: {_dev})

then

$initGetIt(getIt,environment:kReleaseMode?prod:dev,control:{dev:!kReleaseMode})
@windrunner414 windrunner414 changed the title How to control whether to inject a class? Use constants to control whether to inject Apr 7, 2021
@mrverdant13
Copy link

An alternative would be to generate separated injector functions. One per flavor/environment.
Regarding the ones that use filters, they could be grouped in yet another isolated injector function.

@github-actions
Copy link

github-actions bot commented Mar 1, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

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

No branches or pull requests

2 participants