Create to 2 types of state update functions. First one update blocListener state second blocBuilder state
Hi @II11II 馃憢
F.i i have screen there 2 widgets(textfield and button) which depending on state ( loading, loaded, error). Im building 2 widgets in blockbuilder depending data that im receiving from rest api. After successfully building widgets, im sending data(in textfield) to api by button and i need to show pop up in bloclistener . So im crearing extra 2 states (onSuccess, onError). Having sent request by button i m showing popup however i have red death screen in bacground. Bloc consumer updates the BlocBuilder and bloclisterlner state by emit(). I think it would be good choice if there would be two separate update state functions, first for bloclistener state update function and second for BlocBuilder state update function
@II11II can you please provide a link to a sample app which illustrates the problem you're facing? Thanks 馃檹
You're returning return body(context, state); even for OnSuccess and OnError states but Widget body(BuildContext context, OpenDepositLoaded openDepositLoadedState) takes state of type OpenDepositLoaded which is not an OnSuccess or OnError.
You should rather use an enum say enum Status { success, error } that you can incorporate in the existing states that might overlap with your getDeposit call.
Yeap, I had idea to use enum but I cannot pass the response from api I think.
Most helpful comment
You're returning
return body(context, state);even forOnSuccessandOnErrorstates butWidget body(BuildContext context, OpenDepositLoaded openDepositLoadedState)takes state of typeOpenDepositLoadedwhich is not anOnSuccessorOnError.You should rather use an enum say
enum Status { success, error }that you can incorporate in the existing states that might overlap with yourgetDepositcall.