clearChace static method

void clearChace({
  1. bool? clearcache,
})

Implementation

static void clearChace({bool? clearcache}) async {
  // Config.isFirstLogin = false;
  SharedPreferences pref = await SharedPreferences.getInstance();
  String? country = pref.getString(Key_Country);
  String? firebase = pref.getString(Key_firebase);
  String? termdata = pref.getString(term);
  String? emailApplenya = pref.getString(emailApple);
  String? nonce = pref.getString(nonceApple);
  String? tokenApple = pref.getString(idTokenApple);
  String? kodeReferral = pref.getString(KodeREFERERAL);
  String? kodeReferralpermanent = pref.getString(KodeREFERERALPermanet);
  String? keyLanguagedata = pref.getString(keyLanguage);
  String? domain1 = pref.getString(domain);

  String? languageSettingKey = pref.getString(KeyLanguageSetting);
  pref.clear();
  if (clearcache == null) {
    pref.setString(Key_isFirstLogin, "1");
    pref.setString(Key_isOnBoarding, "1");
    if (country != null){
      pref.setString(Key_Country, country);
    }else{
      await FlutterTimezone.getLocalTimezone().then((value) {
        VersionApps apps;
        if (value == "Asia/Singapore" ||
            value.toLowerCase().contains("singapore")) {
          apps = VersionApps.singapura;
          Config.AppVersion = VersionApps.singapura;
        } else {
          apps = VersionApps.indonesia;
          Config.AppVersion = VersionApps.indonesia;
        }
        Preferences.setCountry(Config.AppVersion!);
      });
      // pref.setString(Key_Country, )
    }
    if (firebase != null){
      pref.setString(Key_firebase, firebase!);
    }
    if (keyLanguagedata != null){
      pref.setString(keyLanguage, keyLanguagedata);
    }
    if (domain1 != null){
      pref.setString(domain, domain1);
    }
    if (kodeReferral != null) {
      pref.setString(KodeREFERERAL, kodeReferral);
    }
    if (kodeReferralpermanent != null) {
      pref.setString(KodeREFERERALPermanet, kodeReferralpermanent);
    }

    if (emailApplenya != null) {
      pref.setString(emailApple, emailApplenya);
    }
    if (termdata != null){
      pref.setString(term, termdata);
    }
    if (languageSettingKey != null) {
      pref.setString(KeyLanguageSetting, languageSettingKey);
    }
  } else {}

  // var platform = MethodChannel('sellon.flutter.vicky/appleLogin');
  // try {
  //   print("noncenya apple ${nonce} token $tokenApple");
  //   var revoke = await platform.invokeMethod('revokeAppleLogin',{'nonce':nonce,'idToken':tokenApple});
  //
  //   Preferences.setIdTokenApple("");
  //   Preferences.setNonceApple("");
  //
  // }on PlatformException catch(e){
  //   // batteryLevel = "Failed applename '${e.message}'.";
  // }

  // await pref.setString(Key_apikey, apikey);
}