Flutter application on debug is different than on release on google console

I basically have a flutter application, when I run the app on my physical Android device in debug mode, it runs smoothly as expected, even when I run it in release mode, it runs as expected.
The issue is when I build the appbundle for release to Google Console. The app acts in a strange way where on a fresh install it should display the walkthrough screens (skip screens). on the released app on google console, it doesnt show these screens, it straight away goes to the Login Screen. The api’s as well, same issue.
I want to add that the app of the Google console version only starts to work normally when I go to the App info from my device and clear the data and cache and everything starts to work as intended.

This is my code:
main:
Main

void main() async {
  // Make sure that Flutter is initialized before accessing SharedPreferences
  WidgetsFlutterBinding.ensureInitialized();

  // Restrict the app to portrait mode
  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]);

  await Styles.loadAppConfig();

  // Start the app with the selected home page wrapped in MaterialApp
  runApp(const MyApp(
    homePage: SplashScreen(),
  ));
}

SplashScreen inside the initState after launch screen:
SplashScreen

Timer(const Duration(seconds: 2), () async {
        if (mounted) {
          // Navigate to the home screen after 2 seconds
          // Read the flag from shared preferences
          SharedPreferences prefs = await SharedPreferences.getInstance();

          // Check if this is a new user; if it's null, set it to true
          bool isNewUser = prefs.getBool('isNewUser') ?? true;
          bool isLoggedIn = prefs.getBool('isUserLoggedIn') ?? false;
          bool isLoggedInMemberStored = await prefs.setBool('isLoggedInMemberStored', false);
          bool isSessionExpired = prefs.getBool('isSessionExpired') ?? false;

          // Determine the home page based on the user's status
          Widget homePage = const LoginPage(); // only initialization for the homepage

          // If this is the first launch of the app
          if (isNewUser) {
            // Set the log in to false in shared preferences (confirmation)
            prefs.setBool('isUserLoggedIn', false);

            // Display the walkthrough if not logged in
            if (!isLoggedIn) {
              homePage = WTpageController();
            }
          } else {
            // Lead the user to login if not a new user
            if (isLoggedIn) {
              SessionManager().startSession();
              homePage = NavbarController();
            } else {
              homePage = LoginPage();
            }
          }

          runApp(MyApp(
            homePage: homePage,
          ));
        }
      });

build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def keystorePropertiesFile = rootProject.file('key.properties')
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

def flutterVersionCode = '36' // Update the version code to '2'
def flutterVersionName = '1.0.36' // Update the version name to '1.0.1'

android {
    namespace "com.****.****"
    compileSdk 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.****.****"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            // Default to debug signing config for release builds
            signingConfig signingConfigs.release
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {}

I am not sure, but I think my logic is correct, because its working as intended when I am running the app directly to my Mobile device.
I tried to make changes to the build types of release:

buildTypes {
        release {
            // Default to debug signing config for release builds
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

I added a function and called it after if (isNewUser) { where it clears the app data and cache, because it works normally when I manually delete the cache and data of the app:

Future<void> _clearCacheAndData() async {
    await _clearCache();
    await _clearAppData();
    await _clearSharedPreferences();
  }

  Future<void> _clearCache() async {
    try {
      Directory tempDir = await getTemporaryDirectory();
      Directory cacheDir = await getApplicationCacheDirectory();
      if (tempDir.existsSync()) {
        tempDir.deleteSync(recursive: true);
        print("clearing tempDir");
      }
      if (cacheDir.existsSync()) {
        cacheDir.deleteSync(recursive: true);
        print("clearing cacheDir");
      }
    } catch (e) {
      print("Error clearing cache: $e");
    }
  }

  Future<void> _clearAppData() async {
    try {
      Directory appDir = await getApplicationDocumentsDirectory();
      if (appDir.existsSync()) {
        appDir.deleteSync(recursive: true);
        print("clearing appDir");
      }
    } catch (e) {
      print("Error clearing app data: $e");
    }
  }

  Future<void> _clearSharedPreferences() async {
    try {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      await prefs.clear();
    } catch (e) {
      print("Error clearing shared preferences: $e");
    }
  }

Could this be an issue related to Google Console?
Can you please help me and if needed, I can provide more blocks of code or explain in detail

New contributor

Hadi Emile is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Go to your AndroidManifest.xml, and find these attributes below to check whether they are set to true

android:allowBackup="true"
android:fullBackupContent="true"

It will back up your local storage data even when you uninstalled app, so when you re-install, these data will auto come back.

Eg: some apps did it like Spotify, if you uninstalled this app and then re-install it, open the app and it will auto-login so you don’t need to do this action

For more info, check https://developer.android.com/guide/topics/manifest/application-element#allowbackup

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật