From c880d43a35cd68a911d6e539bb510dbcbcac4061 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 24 Apr 2024 09:24:03 +0200 Subject: [PATCH] Fix map edit not correct --- .../Section/SubSection/Map/map_config.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart index 2161629..b6e04ab 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/map_config.dart @@ -473,11 +473,15 @@ class _MapConfigState extends State { onTap: () { showNewOrUpdateGeoPoint( mapDTO, - mapDTO.points![index], + pointsToShow[index], (GeoPointDTO geoPoint) { setState(() { - mapDTO.points![index] = geoPoint; + var pointToUpdate = pointsToShow[index]; + var pointToUpdateMapDTOPoints = mapDTO.points!.firstWhere((p) => p.longitude == pointToUpdate.longitude && p.latitude == pointToUpdate.latitude); + var mapDTOPointsIndex = mapDTO.points!.indexOf(pointToUpdateMapDTOPoints); + mapDTO.points![mapDTOPointsIndex] = pointToUpdate; mapDTO.points!.sort((a, b) => a.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase().compareTo(b.title!.firstWhere((t) => t.language == 'FR').value!.toLowerCase())); + widget.onChanged(jsonEncode(mapDTO).toString()); }); }, @@ -498,8 +502,7 @@ class _MapConfigState extends State { onTap: () { setState(() { var pointToRemove = pointsToShow[index]; - mapDTO.points = mapDTO.points!.where((p) => p.longitude != pointToRemove.longitude || p.latitude != p.latitude).toList(); - + mapDTO.points = mapDTO.points!.where((p) => p.longitude != pointToRemove.longitude && p.latitude != pointToRemove.latitude).toList(); pointsToShow.removeAt(index); });