title: Struggling with authStateChanges in Flutter
body: <p>Whenever the user closes the app, they have to re-log back in. I looked and tried to implement authStateChanges. But yet my app is still forcing users to log back in after they close the app. In the App class, you can see that I tried to do exactly the authStateChange but nothing seems to be happening, unfortunately.</p>
  <pre><code>Future&lt;void&gt; main() async {
  
  
  WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    runApp(App());
  }
  
  // Firebase Auth Instance
  FirebaseAuth auth = FirebaseAuth.instance;
  
  class MyApp extends StatelessWidget {
    final Future&lt;FirebaseApp&gt; _initialization = Firebase.initializeApp();
  
  
  
  // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
    title: 'Tanbo',
    theme: ThemeData(
      primarySwatch: Colors.blue,
    ),
    home: LoginPage(),
  );
  
  
  }
  }
  
  // This is the main root screen of the Tanbo app
  class App extends StatelessWidget {
    final Future&lt;FirebaseApp&gt; _initialization = Firebase.initializeApp();
  
  
  
  @override
    Widget build(BuildContext context) {
      return FutureBuilder(
        // Initialize FlutterFire
        future: _initialization,
    
  
  builder: (context, snapshot) {
      final user = FirebaseAuth.instance.authStateChanges().listen((User user) {
        if (user == null) {
          print('User signed out');
        } else {
          print('User signed in');
        }
      });
  
      // Check for errors
      if (snapshot.hasError) {
        return ErrorHandler();
      }
  
      // Once complete, show your application
      if (snapshot.connectionState == ConnectionState.done) {
        // If the user isn't logged in, we will be sent to sign up page.
        if (user != null) {
          return MyApp();
        } else {
          // If the user is logged in, TabHandler will be shown.
          return TabHandler();
        }
      }
  
      // Otherwise, show something whilst waiting for initialization to complete
      return LoadingHandler();
    },
  );
  
  
   }
  }
  </code></pre>