title: How to pass user to named route with a stateful widget using Navigator in flutter?
body: <h3>My Setup</h3>
  
  <ul>
  <li>Login Route - asynchronously checks if a user is logged</li>
  <li>Checkin Route - Consists of a main stateful widget and several stateless children widgets that depend on the information of the logged in user</li>
  </ul>
  
  <h3>My Idea</h3>
  
  <ul>
  <li>After the user login is identified on the login route, use Navigator to pass along the user object to the checkin route</li>
  <li>children widgets can receive the user object through their constructor</li>
  </ul>
  
  <h3>My Problem</h3>
  
  <ul>
  <li>the user object is not 'arriving' in the stateful widget of the checkin route</li>
  </ul>
  
  <h3>Files</h3>
  
  <p>Here are the relevant code snippets to check (I added them from more complex files and hope I got all imports correct):</p>
  
  <p><em>Main.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'loginView.dart';
  import 'checkinView.dart';
  
  void main() {
      WidgetsFlutterBinding.ensureInitialized();
      runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
  
      @override
      Widget build(BuildContext context) {
          return MaterialApp(
              initialRoute: '/',
              routes: &lt;String, WidgetBuilder&gt;{
                  '/': (BuildContext context) =&gt; LoginView(),
                  '/checkin': (BuildContext context) =&gt; CheckinView(),
              }
          );
      }
  }
  </code></pre>
  
  <p><em>LoginView.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  
  class LoginView extends StatefulWidget {
      @override
      LoginViewState createState() =&gt; LoginViewState();
  }
  
  class LoginViewState extends State&lt;LoginView&gt; {
      @override
      void initState() {
          super.initState();
  
          checkLoginAndRedirect();
      }
  
      void checkLoginAndRedirect() async {
          FirebaseAuth.instance.currentUser().then((FirebaseUser currUser){
              if(currUser != null){
                  print("[LoginView - user] $currUser");
                  Navigator.pushNamed(context, '/checkin', arguments: {currUser});
              }
          });
      }
  }
  </code></pre>
  
  <p><em>CheckinView.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'checkinList.dart';
  
  class CheckinView extends StatefulWidget {
      final FirebaseUser user;
  
      CheckinView({this.user});
  
      @override
      CheckinViewState createState() {
          print("[CheckinView - user] $user");
          return CheckinViewState();
      }
  }
  
  class CheckinViewState extends State&lt;CheckinView&gt; {
      FirebaseUser _currentUser;
  
      @override
      void initState() {
          super.initState();
  
          setState((){
              _currentUser = widget.user;
          });
      }
  
      @override
      Widget build(BuildContext context) {
  
          print("[CheckinViewState - widget.user] " + widget.user.toString());
  
          return Scaffold(
              body: new Column(
                  children: &lt;Widget&gt;[
                      CheckinList(user: _currentUser)
                  ]
              )
          );
      }
  }
  </code></pre>
  
  <p><em>CheckinList.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  
  class CheckinList extends StatelessWidget{
      FirebaseUser user = null;
  
      CheckinList({this.user = null});
  
      @override
      Widget build(BuildContext context) {
          return Container(
              padding: EdgeInsets.all(30.0),
              child: Text(user['name'])
          );
      }
  }
  </code></pre>