Support for configuring environment variables using configuration file#105213
Support for configuring environment variables using configuration file#105213hai046 wants to merge 2 commits intoflutter:masterfrom hai046:master
Conversation
Add a function: the developer configures a properties file, which will read all the contents of the configuration into the corresponding variables and parameters
Add a function: the developer configures a properties file, which will read all the contents of the configuration into the corresponding variables and parameters
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
why json ? It seem unnecessarily verbose. |
|
|
This seems like a reasonable new feature. However, I think you should start by filing an issue as a new feature request, and then we should discuss the approach from there (for example, I think this should be a new flag, not a magic string parsed from --dart-define). Thank you for contributing and hope to see you on the feature request! |
Add a function: the developer configures a json file, which will read all the contents of the configuration into the corresponding variables and parameters,then you can use it in android and iOS projects with custom variables
1、Define json file
for example: config.json content
2、Use environment in flutter
You can get all json raw content:
Or ,you can get field by
3、Android project
file:
build.gradle4、iOS project
file:
ios/Flutter/Generated.xcconfigfile:
ios/Flutter/flutter_export_environment.shYou can use in Info.plist
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.