In my flutter app, I have two screens namely, AppUpdate and StoreTiming. The AppUpdate screen is shown if the current build is not equal to enforced build (See code below). If current build is equal to enforced build, then the StoreTiming screen is shown. In the case of current build = enforced build, when I start the app, I see the AppUpdate screen appear for about a second and then it is replaced by StoreTming screen. Why does this happen?

 void initState(){ 

    Future<void> _initPackageInfo() async {
        final info = await PackageInfo.fromPlatform();
        setState(() {
          _packageInfo = info;

    Future<void> _enforcedVersion() async {
      final RemoteConfig remoteConfig =  RemoteConfig.instance;
      await remoteConfig.setConfigSettings(RemoteConfigSettings(
                  fetchTimeout: const Duration(seconds: 10),
      await remoteConfig.fetchAndActivate();
       setState(() {
         enforcedBuildNumber = remoteConfig.getString('enforced_build_number');

     Widget build(BuildContext context) {
      return !(_isLoading)?MultiProvider(
  providers: [], 
 child: Consumer<Auth>(builder: (ctx, auth, _) => 
    navigatorKey: navigatorKey,    
    title: 'MyAppName',
    theme: ThemeData(
       textTheme: Theme.of(context).textTheme.apply(
      primaryColor:  Colors.white,
      accentColor:  Color(0xFFF2AD18),
      fontFamily: 'Muli',


Solution 1: Benyamin Beyzaie

Because you make _initPackageInfo(); and _enforcedVersion(); async and async functions need time to complete their works! So before set a correct value on fields in this function build method called and show a page. you can await this function before load completely and set correct values then show a page. but while a async functions is doing their own job you must show some thing to user! You can show loading page if you want and if values are ready show a page... I recommend you to use a state management library like flutter_bloc to have a clean code and better functionallity.