workouttest_app/lib/repository/remote_config_repository.dart
2022-10-19 21:55:17 +02:00

26 lines
839 B
Dart

import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
class RemoteConfigRepository with Logging {
FirebaseRemoteConfig? remoteConfig;
String getConfigValue(String configKey, String baseValue) {
String value = "";
remoteConfig = Cache().remoteConfig;
if (remoteConfig != null) {
remoteConfig!.fetchAndActivate();
Map config = remoteConfig!.getAll();
RemoteConfigValue? configValue = config[configKey];
if (configValue != null && configValue.asString().isNotEmpty) {
log("RemoteConfig $configKey value: ${configValue.asString()}");
if (configValue.asString() == baseValue) {
value = configValue.asString();
}
}
}
return value;
}
}