sendLocation method

void sendLocation()

sends 'location-notify' to all allAtsignsLocationData on every 100 metre location change.

Implementation

void sendLocation() async {
  var permission = await Geolocator.checkPermission();

  if (((permission == LocationPermission.always) ||
      (permission == LocationPermission.whileInUse))) {
    positionStream = Geolocator.getPositionStream(
            locationSettings: const LocationSettings(distanceFilter: 100))
        .listen((myLocation) async {
      //// Enhancement: send location only when myLocation has changed
      if (masterSwitchState) {
        for (var field in allAtsignsLocationData.entries) {
          await prepareLocationDataAndSend(field.key, field.value,
              LatLng(myLocation.latitude, myLocation.longitude));
        }
      }
    });
  }
}