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不会用新值重建。
答案 0 :(得分:0)
该集团没有任何问题,但我一次又一次地传递了同样的问题。现在可以了。