triggerEvent function Null safety
Triggers global Event such as 'pageLoaded', with payload
Implementation
void triggerEvent(String eventName, [String payload = '', Map<String, dynamic> data = const {}]) {
//if(eventName == 'pageLoaded'){ removeAllComponentEvents(); } // remove all component events from previous page
if (simpleEvents.containsKey(eventName)) {
int? length = simpleEvents[eventName]?.length;
length ??= 0;
for(int i=0 ;i<length; i++){
Event evt = simpleEvents[eventName]![i];
if(data.containsKey('target')) evt.target = data['target'];
evt.payload = payload;
evt.callback(evt);
}
}
}