fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.68k stars 848 forks source link

[BUG] Holes in `Polygon`s do not always appear #1924

Closed JaffaKetchup closed 5 days ago

JaffaKetchup commented 1 week ago

What is the bug?

The points of holes in Polygons must be specified in a winding direction opposite to the winding direction used to specify the normal points - otherwise, a hole is not cut.

The bug was introduced in #1901.

How can we reproduce it?

Reverse the order of the inner hole points in the example application.

image

Do you have a potential solution?

Using proper Path.combine techniques in the painter appears to fix the issue:

filledPath = Path.combine(
    PathOperation.xor,
    filledPath,
    Path()..addPolygon(holeOffsets, true),
);

However, this is not supported on the Web HTML backend: https://github.com/flutter/flutter/issues/44572.

Instead, the following line works, but was inadvertantely removed and the introduced bug was not found in testing:

filledPath.fillType = PathFillType.evenOdd;

Platforms

All

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console