Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setState not updating the Icon #53

Open
Punt13140 opened this issue Dec 3, 2021 · 0 comments
Open

setState not updating the Icon #53

Punt13140 opened this issue Dec 3, 2021 · 0 comments

Comments

@Punt13140
Copy link

Describe the bug
I have a variable in my AppState, and I would like to change an icon depending on this variable, after a setState().
It seems the icon is changing only if I go to another page...

To Reproduce
Steps to reproduce the behavior:

  1. Have a variable in your AppState (here it's List<Message> newMessages)
  2. Have an Icon based on this variable :
    List<BottomBarWithSheetItem> lstItems = [
      BottomBarWithSheetItem(
          icon: container.state.newMessages?.isEmpty ? Icons.mail_outline : Icons.mark_email_unread_outlined,
          label: 'MESSAGES'),
      //...
    ];
    return SafeArea(
      child: BottomBarWithSheet(
        controller: _bottomBarController,
       // ...
        items: lstItems,
      )
  1. Have an action to update your variable, and setState()
  void checkNewMessages() async {
      //...
          this.setState(() {
            state.newMessages.add(msg);
          });
  }

Expected behavior
After calling checkNewMessages, the Icon should be mark_email_unread_outlined, but it says mail_outline.

Maybe it's not a bug, maybe It's my code the bug, but I've not find anything in your documentation regarding this...

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant