Closed tologonkudaiberdiuulu closed 3 months ago
This issue is occuring because the equality checking for elements is not working correctly.
A temporary workaround is shown in the invalid issue https://github.com/flutter/flutter/issues/106743: use List.from
to create a new list instance.
Then maybe when overriding "=" operator of Polygon object, you should check manually? Not using listEquals function.
It's not due to that. Its because the list instance is shared, so the list on the oldWidget
and newwidget
are always the same.
I already tried to make like this
It's also not working. Only way to work is creating "mapsPolygons" variable also from new instance of List. Like this:
But it's too complicated, no?
I generally wouldn't recommend doing what you're doing. Instead, use List<List<LatLng>>.map((coords) {}).toList()
on the coordinates
list, in the build
method. This may also resolve the issue as well.
final coordinates = <List<LatLng>>[...];
// inside `build`
PolygonLayer(
polygons: coordinates.map((c) => Polygon(points: c)).toList(),
),
What is the bug?
After adding new points to polygon, it's not updating automatically. You should explicitly add UniqueKey to Polygon widget.
How can we reproduce it?
To reproduce you can view min sample in github. To solve you can uncomment "// key: UniqueKey()," part in map_page.dart file
Do you have a potential solution?
No
Platforms
All
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console