How to display an "Error Msg" if there is no GPS signal

Hi,

I'm using Flutterflow. I've a custom function in my app, that prints the actual device position. This works all fine. I've also added an error massage if the location service is denied, which also works fine. BUT, if the device doesn't have any GPS signal then the page loads forever. And I tried to trigger an error massage for that as well, like "no GPS signal". Unfortunately this does not work.

So, if the location services are denied the app shows my error massage "GPS: deactivated" and I get the following in the debug console: 2022-11-04 13:15:46.174282+0100 Runner[15924:813618] flutter: Error querying user location: Location permissions are permanently denied, we cannot request permissions.

But if the device doesn't have any signal, my error massage doesn't get displayed and I get the following in the console: LOCATION UPDATE FAILURE:Error reason: (null)Error description: The operation couldn’t be completed. (kCLErrorDomain error 0.) 

Does any one know what I have to do, to stop the infinite loading and to generate an error massage if  there is no gps signal?

Here is the full function code:

String positionAsWgs(LatLng? position) {
 if (position == null) {
  return "GPS: no Signal";
 } else {
  var est = position.latitude;
  var north = position.longitude;
  String estString = est.toStringAsFixed(5);
  String northString = north.toStringAsFixed(5);
  var wgs84 = "$estString° N / $northString° E";

  if (wgs84 == "0.00000° N / 0.00000° E") {
   return "GPS: deactivated";
  } else {
   return wgs84;
  }
 }
}`

Replies

There is no "No GPS signal" notification from Core Location. All that you can do is determine that you have not received a location for some period of time, and assume that the signal is lost.

Having said that, what most apps do is simply continue wait, i.e. don't try to present any sort of message to the user.