egovernments / egov-rnd

eGovernments Research and Development
Apache License 2.0
5 stars 13 forks source link

[feat] added check for marker at the start #14

Closed achintya-7 closed 4 months ago

achintya-7 commented 5 months ago

Issue

There was a faulty check of the markers list where we trying to access the first element of that list without ensuring if the list is empty or not

Resolution (Deprecated)

Added a sanity check on the markers list

 LatLng locationSetter() {
    if (alertMarkers.isNotEmpty && alertMarkers.first.locationDetails != null &&  alertMarkers.first.locationDetails!.isNotEmpty) {
      return LatLng(
        alertMarkers.first.locationDetails!.last.latitude,
        alertMarkers.first.locationDetails!.last.longitude,
      );
    } else {
      return custom;
    }
  }

With this, we can prevent access to elements from an empty list.

Resolution 2:

Implemented a feature to have a custom Latitude and Longitude to be added via the .env file

DEFAULT_LATITUDE=17.428446
DEFAULT_LONGITUDE=78.302284

When we are rendering the map on the screen, there is a requirement to provide a centre for the map. It has 2 cases