getVisibleNewsInBounds function

List<NewsMarker> getVisibleNewsInBounds({
  1. required MapController mapController,
  2. required List<NewsMarker> newsMarkers,
  3. required bool showNews,
})

Gets visible news markers within map bounds.

Implementation

List<NewsMarker> getVisibleNewsInBounds({
  required MapController mapController,
  required List<NewsMarker> newsMarkers,
  required bool showNews,
}) {
  if (!showNews || newsMarkers.isEmpty) return [];
  final b = mapController.camera.visibleBounds;
  return newsMarkers
      .where(
        (m) =>
            m.location.latitude >= b.south &&
            m.location.latitude <= b.north &&
            m.location.longitude >= b.west &&
            m.location.longitude <= b.east,
      )
      .toList();
}