MusicPlayer/lib/config.dart

24 lines
584 B
Dart
Raw Normal View History

2022-03-23 18:08:04 +00:00
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");
}
}