我有一个绘制捐赠条的BlocBuilder,但是当对捐赠的更改来自套接字时,由于某种原因,它在调用emit后没有重新绘制UI。
阻塞
BlocBuilder<PatientCardBloc, PatientCardState>(
bloc: PatientCardBloc(),
builder: (context, state) {
return DonatedProgress(
name: patient.firstName,
disease: patient.problem.disease,
currentAmount:
state.status != PatientCardStatus.initialized
? patient.currentAmount
: patient.id == state.patient.id
? state.patient.currentAmount
: patient.currentAmount,
totalAmount: patient.amount,
);
},
),
发射器
_onSetPatientCardFromSoketEvent(
SetPatientCardFromSoketEvent event, Emitter<PatientCardState> emit) {
final patient = event.patient;
if (state.patient.id == patient.id) {
emit(PatientCardState(
patient: patient, status: PatientCardStatus.initialized));
}
}
1条答案
按热度按时间zour9fqk1#
阻塞:患者卡阻塞()
在定义BlocBuilder时不应创建新的Bloc对象。请改用BlocProvider的create方法。