fromString static method

Configuration fromString(
  1. String data
)

Implementation

static Configuration fromString(String data) {
  final yamlMap = _loadYaml(data);

  if (!yamlMap.containsKey(_FLUTTER_APPLICATION_ID_KEY) ||
      !(yamlMap[_FLUTTER_APPLICATION_ID_KEY] is YamlMap)) {
    throw NoConfigFoundException();
  }

  if (!yamlMap.containsKey(_DEEP_LINK_KEY) ||
      !(yamlMap[_DEEP_LINK_KEY] is YamlMap)) {
    throw NoConfigFoundException();
  }

  if (!yamlMap.containsKey(__BUILD_VERSION_KEY) ||
      !(yamlMap[__BUILD_VERSION_KEY] is YamlMap)) {
    throw NoConfigFoundException();
  }

  if (!yamlMap.containsKey(_ADMOB_KEY) || !(yamlMap[_ADMOB_KEY] is YamlMap)) {
    throw NoConfigFoundException();
  }

  if (!yamlMap.containsKey(_FORCE_REMOTE_CONTROL_KEY) ||
      !(yamlMap[_FORCE_REMOTE_CONTROL_KEY] is bool)) {
    throw NoConfigFoundException();
  }

  if (!yamlMap.containsKey(_USE_LOCAL_KEY) ||
      !(yamlMap[_USE_LOCAL_KEY] is bool)) {
    throw NoConfigFoundException();
  }

  return Configuration(
    android: PlatformConfiguration.fromYamlMap(
        yamlMap[_FLUTTER_APPLICATION_ID_KEY][__ANDROID_KEY]),
    ios: PlatformConfiguration.fromYamlMap(
        yamlMap[_FLUTTER_APPLICATION_ID_KEY][__IOS_KEY]),
    admob: AdMob.fromYamlMap(
      yamlMap[_ADMOB_KEY],
    ),
    deepLink: DeepLink.fromYamlMap(
      yamlMap[_DEEP_LINK_KEY],
    ),
    buildVersion: BuildVersion.fromYamlMap(
      yamlMap[__BUILD_VERSION_KEY],
    ),
    forceRemoteControl: yamlMap[_FORCE_REMOTE_CONTROL_KEY],
    useLocal: yamlMap[_USE_LOCAL_KEY],
  );
}