useRememberConfig method

dynamic useRememberConfig()

Implementation

useRememberConfig() {
  final rememberBeautyConfig =
      getConfig().basicConfig?.rememberBeautyConfig ?? false;
  final rememberVirtualBackgroundConfig =
      getConfig().basicConfig?.rememberVirtualBackgroundConfig ?? false;
  final enableVirtualBackground =
      getConfig().basicConfig?.enableVirtualBackground ?? false;
  if (rememberBeautyConfig) {
    final beautyConfig = sharedPreferences.getString(
      "beautyConfig-${_config.userId}",
    );
    if (beautyConfig != null) {
      final beautyConfigJson = jsonDecode(beautyConfig);
      final beautyLevel = beautyConfigJson['beautyLevel'];
      final whitenessLevel = beautyConfigJson['whitenessLevel'];
      final ruddinessLevel = beautyConfigJson['ruddinessLevel'];
      setBeautyStyle(
        TRTCBeautyStyle.smooth,
        beautyLevel,
        whitenessLevel,
        ruddinessLevel,
      );
    }
  }
  if (rememberVirtualBackgroundConfig && enableVirtualBackground) {
    final virtualBackgroundConfig = sharedPreferences.getString(
      "virtualBackgroundConfig-${_config.userId}",
    );
    if (virtualBackgroundConfig != null) {
      final virtualBackgroundConfigJson = jsonDecode(virtualBackgroundConfig);
      final key = virtualBackgroundConfigJson['key'];
      if (key is String) {
        final index = getVirtualBackgroundData().findIndexByKey(key);
        if (index != null) {
          setVirtualBackgroundByIndex(index);
          return;
        }
      }
      final index = virtualBackgroundConfigJson['index'];
      if (index is int) {
        setVirtualBackgroundByIndex(index);
      }
    }
  }
}