getViewportBoundsOrNull method

Future<LatLngBounds?> getViewportBoundsOrNull()

getViewportBounds for callers that would rather handle a dead map than catch: null means there is no live map to read bounds from.

Implementation

Future<generic.LatLngBounds?> getViewportBoundsOrNull() async {
  final visibleRegion = await _withMap((map) => map.getVisibleRegion());
  if (visibleRegion == null) return null;
  return generic.LatLngBounds.fromSouthWestNorthEast(
    visibleRegion.southwest.toLatLng(),
    visibleRegion.northeast.toLatLng(),
  );
}