title: Flutter provider not updating state
body: <p>I'm still relatively new to flutter and even newer to Provider so I may be entirely off with this but from what I've read it looks correct.</p>
  
  <p>General idea is there's a header widget with a button that will either open an endrawer or bring the user to a login page depending on the state of the app.</p>
  
  <p>Login works and the states all are working correctly but only on the login widget. When the user is routed back to the main screen - the state is still in its default state even though the state gets set on a successful login.</p>
  
  <p>The widget tree is like so:<br/>
  <strong>Main</strong><br/>
  |_ <strong>HomeScreen</strong><br/>
  |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|_ <strong>AppHeader</strong><br/>
  |_ <strong>Login</strong><br/></p>
  
  <p><br></p>
  
  <p><em>main.dart</em></p>
  
  <pre class="lang-dart prettyprint-override"><code>  Widget build(BuildContext context) {
      return MultiProvider (
            providers: [
              ChangeNotifierProvider (create: (_) =&gt; LoginState(),)
            ],
            child: MaterialApp(
              title: kAppTitle,
              theme: alcDefaultLightTheme(),
              home: HomeScreen(title: "kAppTitle"),
              localizationsDelegates: [
                GlobalMaterialLocalizations.delegate,
                GlobalWidgetsLocalizations.delegate,
                GlobalCupertinoLocalizations.delegate,
                const AlcLocalizationsDelegate(),
              ],
              supportedLocales: [
                const Locale(kEn),
                const Locale(kFr),
              ],
              initialRoute: HomeScreen.id,
              routes: {
                LoadingScreen.id: (context) =&gt; LoadingScreen(),
                HomeScreen.id: (context) =&gt; HomeScreen(title: kAppTitle),
              }),
      );
    }
  </code></pre>
  
  <p><br/>
  <em>home_screen.dart</em></p>
  
  <pre class="lang-dart prettyprint-override"><code>
  class HomeScreen extends StatefulWidget {
    static const String id = 'home_screen';
  
    HomeScreen({Key key, this.title}) : super(key: key);
    final String title;
    @override
    _HomeScreenState createState() =&gt; _HomeScreenState();
  }
  
  class _HomeScreenState extends State&lt;HomeScreen&gt; {
    final GlobalKey&lt;ScaffoldState&gt; _scaffoldKey = new GlobalKey&lt;ScaffoldState&gt;();
  
    AccountDrawerOpen() {
      _scaffoldKey.currentState.openEndDrawer();
      FirebaseAnalytics().logEvent(
        name: 'account_drawer_open',
      );
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        ...display code here
        body: AppHeader()
      );}
  }
  
  </code></pre>
  
  <p><br>
  And this is where I need to access the state to determine if the player is logged in or not
  <br>
  <em>app_header.dart</em></p>
  
  <pre class="lang-dart prettyprint-override"><code>import 'package:provider/provider.dart';
  
  class AppHeader extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
  
      LoginState testLoginState = Provider.of&lt;LoginState&gt;(context);
  
      return Column(
        children: &lt;Widget&gt;[
          FlatButton(
            child: Text('Check state'),
            onPressed: () {
              print("APP HEADER | STATE IS NOW ${testLoginState.status}");
            },
          )
        ],
      );
    }
  }
  </code></pre>
  
  <p>Lastly, here's my LoginState.dart</p>
  
  <pre class="lang-dart prettyprint-override"><code>enum Status {
    Authenticated,
    Authenticating,
    Unauthenticated,
    InvalidLogin
  }
  
  class LoginState with ChangeNotifier {
    Status _status = Status.Unauthenticated;
  
    Status get status =&gt; _status;
  
    Future signIn(String email, String password) async {
      try {
        _status = Status.Authenticating;
        notifyListeners();
  
        ... goes to the DB, some logic happens and returns true
  
        _status = Status.Authenticated;
        notifyListeners();
        print("FROM LOGIN STATE: $_status");
  
      } catch (e) {
        print('Oops');
        _status = Status.InvalidLogin;
        notifyListeners();
      }
    }
  </code></pre>
  
  <p>Any help is appreciated, thanks for your help.</p>