Flutter BloC not refresh my view (counter app)

后端 未结 3 1386
执笔经年
执笔经年 2021-01-16 03:37

I\'m trying BloC library with Counter test app but I have a little problem on my view when I use object to increment/decrement my counter. MyObject.MyProperty increment or d

3条回答
  •  独厮守ぢ
    2021-01-16 03:43

    I see you are using some kind of redux implementation and i'm not quite sure how this handles the rebuild when actions are dispatched.

    As my knowledge you are dispatching an action that update some property on the widget but you are never calling setState again, so the widget is not being rebuild.

    Try to call the increment or decrement actions inside a setState function.

    Something like this:

    onPressed: () {
     setState(() => counterBloc.dispatch(CounterEvent.decrement));
    },
    

提交回复
热议问题