title: Flutter Cubit: good way to get stored variable?
body: <p>I'm using Flutter and Cubit for the first time, and I would like to know if this is a good way to retrieve a stored variable, in my cas the current loggued user.</p>
  <p>After loggued in, the user can go to his profile page and see it/update it.</p>
  <p>Login form:</p>
  <pre class="lang-dart prettyprint-override"><code>submit(BuildContext context) async {
      if (_formKey.currentState!.validate()) {
        _formKey.currentState!.save();
  
        final authCubit = context.read&lt;AuthCubit&gt;();
        authCubit.login(
          email: _data.email!,
          password: _data.password!,
          deviceName: _deviceInfos.deviceName,
        );
      }
    }
  </code></pre>
  <p>AuthCubit: login method:</p>
  <pre class="lang-dart prettyprint-override"><code>class AuthCubit extends Cubit&lt;AuthState&gt; {
    dynamic user;
    
    Future&lt;void&gt; login({
      required String email,
      required String password,
      required String deviceName,
    }) async {
      emit(AuthLoading());
  
      // Get the user from the API
      this.user = apiResponse['user'];
  
      emit(AuthConnected(user));
    }
  }
  </code></pre>
  <p>Profile page:</p>
  <pre class="lang-dart prettyprint-override"><code>Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('Profile'),
        ),
        body: BlocBuilder&lt;AuthCubit, AuthState&gt;(
          builder: (context, state) {
            final user = context.read&lt;AuthCubit&gt;().user;
  
            return Center(
              child: Column(
                children: &lt;Widget&gt;[
                  Text('Hello, ' + (user != null ? user['name'] : 'stranger.')),
                  ElevatedButton(
                    onPressed: () {
                      context.read&lt;AuthCubit&gt;().logout();
                    },
                    child: Text('Logoout'),
                  ),
                ],
              ),
            );
          },
        ),
      );
  }
  </code></pre>
  <p>Any suggestion/advice is really appreciated. Thanks!</p>