Last active
December 8, 2022 04:48
-
-
Save gildaswise/18c45b7d6107521f4b9eb84a17966298 to your computer and use it in GitHub Desktop.
Gists from the --dart-define article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dartDefinesString = Bundle.main.infoDictionary!["DART_DEFINES"] as! String | |
var dartDefinesDictionary = [String:String]() | |
for definedValue in dartDefinesString.components(separatedBy: ",") { | |
let decoded = String(data: Data(base64Encoded: definedValue)!, encoding: .utf8)! | |
let values = decoded.components(separatedBy: "=") | |
dartDefinesDictionary[values[0]] = values[1] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dartEnvironmentVariables = [] | |
if (project.hasProperty('dart-defines')) { | |
dartEnvironmentVariables = project.property('dart-defines') | |
.split(',') | |
.collectEntries { entry -> | |
def pair = new String(entry.decodeBase64(), 'UTF-8').split('=') | |
[(pair.first()): pair.last()] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Environment { | |
static const API_KEY = String.fromEnvironment('API_KEY'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment