From 10cbed55c4a246d62038bbba2a87864fd79013ab Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 6 Aug 2025 21:41:42 -0500 Subject: [PATCH] fix: crash when rendering heatmap on Android (#20740) --- .../presentation/widgets/map/map.widget.dart | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/mobile/lib/presentation/widgets/map/map.widget.dart b/mobile/lib/presentation/widgets/map/map.widget.dart index 6eab5741d2..49af53f1eb 100644 --- a/mobile/lib/presentation/widgets/map/map.widget.dart +++ b/mobile/lib/presentation/widgets/map/map.widget.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -68,11 +69,30 @@ class _DriftMapState extends ConsumerState { const CustomSourceProperties(data: {'type': 'FeatureCollection', 'features': []}), ); - await controller.addHeatmapLayer( - MapUtils.defaultSourceId, - MapUtils.defaultHeatMapLayerId, - MapUtils.defaultHeatmapLayerProperties, - ); + if (Platform.isAndroid) { + await controller.addCircleLayer( + MapUtils.defaultSourceId, + MapUtils.defaultHeatMapLayerId, + const CircleLayerProperties( + circleRadius: 10, + circleColor: "rgba(150,86,34,0.7)", + circleBlur: 1.0, + circleOpacity: 0.7, + circleStrokeWidth: 0.1, + circleStrokeColor: "rgba(203,46,19,0.5)", + circleStrokeOpacity: 0.7, + ), + ); + } + + if (Platform.isIOS) { + await controller.addHeatmapLayer( + MapUtils.defaultSourceId, + MapUtils.defaultHeatMapLayerId, + MapUtils.defaultHeatmapLayerProperties, + ); + } + _debouncer.run(setBounds); controller.addListener(onMapMoved); }