skip to Main Content

Recently I publish my mobile application but there is a unique problem. In some devices people download application in google play and easily use the application. But some devices has need to clear all application data from settings then open again because if they don’t do this they can’t see onboarding screen and also can’t fetch data from internet. In flutter I basically use Hive local storage at main dart to route after installation

//Here if onBoard box is true user will see welcomescreen
if (Hive.box('settings').get('onBoard') == true) {
screen = const WelcomeScreen();
}
//Here if user already registered but click sign out button isRegistered box will be false and user
//will go LoginPage again

else if(Hive.box('settings').get('isRegistered') == false){
screen = const LoginPageDesign();
}
//! If on boarding not true (false or null) user will route OnBoarding page
else {
screen = const OnBoarding();
}

2

Answers


  1. Chosen as BEST ANSWER
     switch(Hive.box('settings').get('isRegistered')){
      
      case null:
      screen = const OnBoarding();
      break;
    
      case false:
      screen = const LoginPageDesign();
      break;
    
      case true:
      screen = const WelcomeScreen();
      break;
    

    }

    Interestingly once I tested with internal test, Android 13 real devices has no problem it goes first onBoaring but with Android 10 it goes directly WelcomeScreen I don't understand how it is possible to take true for this situation should always null at fresh start.

    EDIT : Problem is interestingly fixed once add another Hive.box for registeration ...


  2. The problem is some android devices backsup local storage data to the cloud. You can go through this article from android: https://developer.android.com/guide/topics/data/autobackup.html

    So, to overcome this issue, just navigate to your AndroidManifest and do the following just under application tag:

    <application
    ...
    android:allowBackup="false"
    android:fullBackupContent="false"
    tools:replace="android:allowBackup"
    ...
    </application>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search