Skip to content

Instantly share code, notes, and snippets.

@gildaswise
Last active December 8, 2022 04:48
Show Gist options
  • Save gildaswise/18c45b7d6107521f4b9eb84a17966298 to your computer and use it in GitHub Desktop.
Save gildaswise/18c45b7d6107521f4b9eb84a17966298 to your computer and use it in GitHub Desktop.
Gists from the --dart-define article
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]
}
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()]
}
}
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