sendLocation method
void
sendLocation()
Implementation
void sendLocation() async {
var permission = await Geolocator.checkPermission();
if (((permission == LocationPermission.always) ||
(permission == LocationPermission.whileInUse))) {
/// The stream doesnt run until 100m is covered
/// So, we send data once
var _currentMyLatLng = await getMyLocation();
if (_currentMyLatLng != null && masterSwitchState) {
await Future.forEach(eventsToShareLocationWith,
(dynamic notification) async {
// ignore: await_only_futures
await prepareLocationDataAndSend(notification,
LatLng(_currentMyLatLng.latitude, _currentMyLatLng.longitude));
});
if (MixedConstants.isDedicated) {
// ignore: unawaited_futures
SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
}
}
///
positionStream = Geolocator.getPositionStream(distanceFilter: 100)
.listen((myLocation) async {
if (masterSwitchState) {
await Future.forEach(eventsToShareLocationWith,
(dynamic notification) async {
// ignore: unawaited_futures
prepareLocationDataAndSend(notification,
LatLng(myLocation.latitude, myLocation.longitude));
});
if (MixedConstants.isDedicated) {
// ignore: unawaited_futures
SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);
}
}
});
}
}