I have a page in that page I have 4 widget and for those 4 widget I have to make 4 api call(1 for each) so I have created the 4 event and I call the event. Event adding is working fine but execution of event is not happening paralleled 2nd event is executing only after first one get executed.
Hi @Virendra-Varma 馃憢
You could add a single event and make those requests using Future.wait([futures]) which will execute them parallelly.
Feel free to comment if that doesn't solve your issue. 馃憤
ok
and how would I yield the result
Future.wait returns the responses in form of a List<Object>, so you'd have something like:
final responses = await Future.wait([futures]);
final response1 = responses.first;
final response2 = responses[1];
...
Based on those you'd compose your state and yield it in mapEventToState.
Alternatively you could aggregate your requests in your repository layer and expose a single result, but that's up to you to decide what you need. 馃憤
Most helpful comment
Future.waitreturns the responses in form of aList<Object>, so you'd have something like:Based on those you'd compose your state and yield it in
mapEventToState.Alternatively you could aggregate your requests in your repository layer and expose a single result, but that's up to you to decide what you need. 馃憤