title: Provider method returns null when called from another page
body: <p>I have an application where I log my user, save it inside a provider state and then try to fetch the saved state inside a different page, but it keeps returning null.</p>
  
  <p>My code:</p>
  
  <p>main.dart:</p>
  
  <pre><code>void main() =&gt; runApp(
      MultiProvider(
          providers: [
            ChangeNotifierProvider(create: (_) =&gt; AuthenticationProvider())
          ],
          child:MyApp()
      )
  );
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.indigo,
          primaryColor: Colors.indigo,
          brightness: Brightness.light,
          scaffoldBackgroundColor: Colors.white
        ),
        home: Consumer&lt;AuthenticationProvider&gt;(
          builder: (context, AuthenticationProvider user, _) {
            return showScreen(user);
          },
        ),
        routes: {
          '/login': (context) =&gt; Login(),
          '/home': (context) =&gt; Home(),
          '/extrato': (context) =&gt; Extrato(),
          '/atendimento': (context) =&gt; AtendimentoPage(),
          '/informacoes': (context) =&gt; Informacoes(),
          '/manual': (context) =&gt; Manual(),
          '/recarga': (context) =&gt; RecargaPage(),
          '/splah': (context) =&gt; Splash()
        }
      );
    }
  }
  
  Widget showScreen(user) {
    switch (user.status) {
      case Status.Uninitialized:
        return Splash();
      case Status.Unauthenticated:
      case Status.Authenticating:
        return Login();
      case Status.Authenticated:
        return Home();
    }
  }
  </code></pre>
  
  <p>authentication_provider.dart:</p>
  
  <pre><code>class AuthenticationProvider extends ChangeNotifier {
  
    AuthenticationProvider(){
  
    }
  
    PontoVenda _user;
  
    PontoVenda get user =&gt; _user;
  
    Status _status = Status.Uninitialized;
  
    Status get status =&gt; _status;
  
    Future login(String login, String senha) async {
      try {
  
        final response = await AuthenticationService().authenticateUser(login, senha);
  
        final mapResponse = _parseLogin(response);
  
        _status = Status.Authenticated;
        _user = await PontoVendaService().fetchPontoVenda(mapResponse["token"]);
  
        print(_user.data);
  
        notifyListeners();
  
        return user;
  
      } catch(e) {
        print(e);
        _status = Status.Unauthenticated;
        notifyListeners();
      }
    }
  
    Map&lt;String, dynamic&gt; _parseLogin(response) {
      return json.decode(response.body);
    }
  
    void logOut() async {
      _user = null;
      _status = Status.Unauthenticated;
      notifyListeners();
    }
  
  }
  </code></pre>
  
  <p>home.dart (where I'm trying to fetch the user state data):</p>
  
  <pre><code>class Test extends StatelessWidget {
    final ExtratoService _extratoService = ExtratoService();
    final AtendimentoService _atendimentoService = AtendimentoService();
  
    @override
    Widget build(BuildContext context) {
      // Trying here
      final testingStuff = Provider.of&lt;AuthenticationProvider&gt;(context);
  
      print(testingStuff.user);
  
      return ListView(
        children: &lt;Widget&gt;[
          Stack(
            alignment: Alignment.center,
            children: &lt;Widget&gt;[
              Image(image: AssetImage("assets/images/box-03.png"),height: 300, width: double.infinity, fit: BoxFit.cover,),
              Container(
                height: 300,
                color: Colors.black54.withOpacity(0.4),
              ),
              Positioned(
                  bottom: 60,
                  child: Container(
                      padding: EdgeInsets.all(20),
                      child: Column(
                        children: &lt;Widget&gt;[
                          Text('Bem vinda(o), fulano', style: TextStyle(color: Colors.white, fontSize: 18)),
                          Text('Seu saldo atual', style: TextStyle(color: Colors.white, fontSize: 18)),
                          Text('R\$300.00', style: TextStyle(color: Colors.white, fontSize: 35),)
  
                        ],
                      )
                  )
              )
            ],
          ),
          _previewCards('Últimas recargas', context, _ultimasRecargas(context)),
          _previewCards('Últimos atendimentos', context, _ultimosAtendimentos(context))
        ],
      );
    }
  
    ...
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>login.dart</p>
  
  <pre><code>class Login extends StatefulWidget {
  
    @override
    _LoginState createState() =&gt; _LoginState();
  }
  
  class _LoginState extends State&lt;Login&gt; {
  
    @override
    void initState() {
      super.initState();
      SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
    }
  
    final _formKey=GlobalKey&lt;FormState&gt;();
  
    final _tLogin = TextEditingController(text: "3m3");
  
    final _tSenha = TextEditingController(text: "601733");
  
    bool _showProgress = false;
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: _body(),
      );
    }
  
    Widget _body() {
      return Form(
        key: _formKey,
        child: Container(
          padding: EdgeInsets.all(16),
          child: ListView(
            children: &lt;Widget&gt;[
              _img(),
              AppText(
                "Login",
                  "Digite o login",
                  controller: _tLogin,
                  validator: _validateLogin,
              ),
              SizedBox(height: 20),
              AppText("Senha",
                  "Digite a senha",
                  controller: _tSenha,
                  password: true,
                  validator: _validateSenha,
              ),
              SizedBox(
                  height: 20
              ),
              AppButton(
                "Entrar",
                onPressed: _onClickLogin,
                showProgress: _showProgress,
              )
            ],
          ),
        ),
      );
    }
  
    Widget _img() {
      return Image.asset("assets/images/logo.png");
    }
  
    void _onClickLogin() async {
      if(!_formKey.currentState.validate()) {
        return;
      }
  
      setState(() {
        _showProgress = true;
      });
  
      final user = await AuthenticationProvider().login(_tLogin.text, _tSenha.text);
  PontoVendaProvider().getPontosVendasList(user.token);
  
      push(context, Home(), replace: true);
  
      setState(() {
        _showProgress = false;
      });
    }
  
    String _validateLogin(String text) {
        if (text.isEmpty) {
          return "Digite o login";
        }
        return null;
      }
  
    String _validateSenha(String text) {
      if (text.isEmpty) {
        return "Digite a senha";
      }
      if(text.length &lt; 3) {
        return "A senha precisa ter pelo menos 3 digitos";
      }
      return null;
    }
  
  }
  </code></pre>
  
  <p>I'm not sure what is really happening. I'm trying to fetch the user that should be saved inside the authentication provider state but it just returns null. I placed my ChangeNotifier way above in the widget tree, but it still doesn't work. Can anyone please help?</p>