Eternalcode
Eternalcode

Reputation: 2412

Order of event listeners

Is there a way to manually order the execution of event listeners for the same element?

For example If I have two methods that has onClick() listeners.

void A(Element el) {
   el.onClick((event) => model.get("inside"));
}

void B(Element el) {
   ....
   el.onClick((event) => expect(model.get("inside"), isNotNull));
   ....
}

Thanks, everyone.

Upvotes: 0

Views: 144

Answers (1)

Harry Terkelsen
Harry Terkelsen

Reputation: 2714

There is no way to specify the order in which event listeners will fire. You could force the listener in B to wait on the listener in A by having a Completer that you call complete on after the listener in A finishes. Then you can have the listener in B wait on the completer.

Upvotes: 4

Related Questions