title: Flutter change bool (with setState) in other dart file
body: <p>I'm trying to make a splash screen with stacks. When everything is done loading, i want to change the bool splashScreenIsLoading to false.</p>
  
  <p>This is my code in my main.dart</p>
  
  <pre><code>bool splashScreenIsLoading = true;
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: Stack(
          children: &lt;Widget&gt;[
            loginScreen(),
            showRightSplash(),
          ],
        ),
      );
    }
  }
  
  class showRightSplash extends StatefulWidget {
    @override
    _showRightSplashState createState() =&gt; _showRightSplashState();
  }
  
  class _showRightSplashState extends State&lt;showRightSplash&gt; {
    @override
    Widget build(BuildContext context) {
      return splashScreenIsLoading == true ? splashScreen() : splashScreen2();
    }
  }
  
  splashScreen() {
    return Text(
      "SHOW SPLASH SCREEN",
      style: TextStyle(fontSize: 50, color: Colors.red),
    );
  }
  
  splashScreen2() {
    return Text(
      "HIDE SPLASH SCREEN",
      style: TextStyle(fontSize: 50, color: Colors.red),
    );
  }
  </code></pre>
  
  <p>In my file (a different .dart file) loginScreen(), I have this in initState</p>
  
  <pre><code>void initState() {
      super.initState();
      pageController = PageController(initialPage: 0);
      doTasks()
      setState(() {
        splashScreenIsLoading = false;
      });
    }
  </code></pre>
  
  <p>It doesn't work, only when I hot reload when everything is loaded. Is there a solution for this?</p>