MusicPlayer/lib/config.dart

24 lines
584 B
Dart

class Config {
final String apiURL;
final String apiToken;
const Config({required this.apiURL, required this.apiToken});
}
late Config config;
void loadConfig() {
config = const Config(
apiURL: String.fromEnvironment("API_URL"),
apiToken: String.fromEnvironment("API_TOKEN"),
);
// ignore: avoid_print
print("Using ${config.apiURL} / Token; ${config.apiToken}");
if (config.apiURL == "" || config.apiToken == "") {
throw Exception("You must define API_URL and API_TOKEN. This can be done "
"with the --dart-define arg to run or build");
}
}