1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] NotifierProvider being set without executing the code in Flutter app

Discussão em 'Mobile' iniciado por Stack, Novembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I have a flutter web app where I set a global variable, companyID, in a global notifier provider when the user successfully logs in.

    In the first line of code below, I set the global variable, newUser, to "false".

    In the last line of code in the snippet below, I update the global variable, companyId. However, when this line of code executes, newUser gets set to "true". I don't know why or how this is happening. I have set a breakpoint in the code where I set the newUser variable but that code doesn't get executed.

    Here is the login code: ref.read(globalsNotifierProvider.notifier).updatenewUser(false);

    final DocumentSnapshot _currentUserProfile =
    await usersRef.doc(globals.currentUid).get();

    if (_currentUserProfile != null) {
    ///
    /// Update the global provider
    ///
    ref
    .read(globalsNotifierProvider.notifier)
    .updatecompanyId(_currentUserProfile.get('companyId'));


    In the code above, I set the newUser variable to "false" because this is not a new user. However, in this line of code below, the newUser variable gets set to "true".

    ref
    .read(globalsNotifierProvider.notifier)
    .updatecompanyId(_currentUserProfile.get('companyId'));


    Why is this happening? Thanks in advance

    Continue reading...

Compartilhe esta Página