addMember method
Will be called from addDataToList or mapUpdatedEventDataToWidget
Implementation
Future<void> addMember(EventNotificationModel _newData) async {
if (eventsToShareLocationWith
.indexWhere((element) => element.key == _newData.key) >
-1) {
return;
}
var myLocation = await getMyLocation();
if (myLocation != null) {
if (masterSwitchState) {
await prepareLocationDataAndSend(_newData, myLocation);
if (MixedConstants.isDedicated) {
// ignore: unawaited_futures
SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
}
} else {
/// method from main app
if (locationPromptDialog != null) {
eventsToShareLocationWith.add(_newData);
locationPromptDialog!();
/// return as when main switch is turned on, it will send location to all.
return;
}
}
} else {
if (AtEventNotificationListener().navKey != null) {
CustomToast().show('Location permission not granted',
AtEventNotificationListener().navKey!.currentContext);
}
}
// add
eventsToShareLocationWith.add(_newData);
print(
'after adding atsignsToShareLocationWith length ${eventsToShareLocationWith.length}');
}