【问题标题】:Bloc library state not rebuilding [closed]Bloc库状态未重建[关闭]
【发布时间】:2020-09-06 14:09:54
【问题描述】:
 Widget build(BuildContext context) {
return Scaffold(
  body: MultiBlocListener(
    listeners: [
      BlocListener<QuestionholderBloc, QuestionholderState>(
        listener: (context, state) {
          if (state is NoQuestions) {
            _dbbloc.add(GetQuestions());
          } else if (state is HasQuestions) {
            _statusbloc.add(GetQuestion());
          }
        },
      ),
      BlocListener<DatabaseBloc, DatabaseState>(
        listener: (context, state) {
          if (state is Loaded) {
            _statusbloc.add(SetQuestions(questionsToSet: state.questions));
          }
        },
      ),
    ],
    child: BlocBuilder<QuestionholderBloc, QuestionholderState>(
      builder: (context, state) {
        if (state is QuestionLoaded) {
          return QuestionWidget(question: state.question);
        } else {
          return CircularProgressIndicator();
        }
      },
    ),
  ),
);

} }

我在 QuestionWidget 上有一个触发 getQuestion 事件的按钮。 最初,一切正常,但 QuestionWidget 不会在按下按钮时使用新值重建。

【问题讨论】:

    标签: flutter flutter-dependencies bloc


    【解决方案1】:

    该集团没有任何问题,但我一遍又一遍地提出同样的问题。现在可以了。

    【讨论】:

      猜你喜欢
      • 2020-06-17
      • 2020-04-17
      • 2021-03-19
      • 2020-10-10
      • 2020-05-06
      • 2021-10-22
      • 2020-08-03
      • 2021-01-07
      • 2020-03-26
      相关资源
      最近更新 更多