@@ -32,13 +32,17 @@ base class _PolygonPainter<R extends Object>
3232 /// This may improve performance: see [polygonLabels] for more information.
3333 final bool drawLabelsLast;
3434
35+ /// See [PolygonLayer.debugAltRenderer]
36+ final bool debugAltRenderer;
37+
3538 /// Create a new [_PolygonPainter] instance.
3639 _PolygonPainter ({
3740 required this .polygons,
3841 required this .triangles,
3942 required super .camera,
4043 required this .polygonLabels,
4144 required this .drawLabelsLast,
45+ required this .debugAltRenderer,
4246 required super .hitNotifier,
4347 }) : bounds = camera.visibleBounds;
4448
@@ -125,6 +129,50 @@ base class _PolygonPainter<R extends Object>
125129 }
126130 final vertices = Vertices .raw (VertexMode .triangles, points);
127131 canvas.drawVertices (vertices, BlendMode .src, paint);
132+
133+ if (debugAltRenderer) {
134+ for (int i = 0 ; i < trianglePoints.length; i += 3 ) {
135+ canvas.drawCircle (
136+ trianglePoints[i],
137+ 5 ,
138+ Paint ()..color = const Color (0x7EFF0000 ),
139+ );
140+ canvas.drawCircle (
141+ trianglePoints[i + 1 ],
142+ 5 ,
143+ Paint ()..color = const Color (0x7E00FF00 ),
144+ );
145+ canvas.drawCircle (
146+ trianglePoints[i + 2 ],
147+ 5 ,
148+ Paint ()..color = const Color (0x7E0000FF ),
149+ );
150+
151+ final path = Path ()
152+ ..addPolygon (
153+ [
154+ trianglePoints[i],
155+ trianglePoints[i + 1 ],
156+ trianglePoints[i + 2 ],
157+ ],
158+ true ,
159+ );
160+
161+ canvas.drawPath (
162+ path,
163+ Paint ()
164+ ..color = const Color (0x7EFFFFFF )
165+ ..style = PaintingStyle .fill,
166+ );
167+
168+ canvas.drawPath (
169+ path,
170+ Paint ()
171+ ..color = const Color (0xFF000000 )
172+ ..style = PaintingStyle .stroke,
173+ );
174+ }
175+ }
128176 } else {
129177 canvas.drawPath (filledPath, paint);
130178 }
@@ -163,6 +211,25 @@ base class _PolygonPainter<R extends Object>
163211 polygonTriangles != null ? projectedPolygon.holePoints : null ,
164212 );
165213
214+ if (debugAltRenderer) {
215+ const offsetsLabelStyle = TextStyle (
216+ color: Color (0xFF000000 ),
217+ fontSize: 16 ,
218+ );
219+
220+ for (int i = 0 ; i < fillOffsets.length; i++ ) {
221+ TextPainter (
222+ text: TextSpan (
223+ text: i.toString (),
224+ style: offsetsLabelStyle,
225+ ),
226+ textDirection: TextDirection .ltr,
227+ )
228+ ..layout (maxWidth: 100 )
229+ ..paint (canvas, fillOffsets[i]);
230+ }
231+ }
232+
166233 // The hash is based on the polygons visual properties. If the hash from
167234 // the current and the previous polygon no longer match, we need to flush
168235 // the batch previous polygons.
@@ -323,6 +390,7 @@ base class _PolygonPainter<R extends Object>
323390 final isSolid = polygon.pattern == const StrokePattern .solid ();
324391 final isDashed = polygon.pattern.segments != null ;
325392 final isDotted = polygon.pattern.spacingFactor != null ;
393+
326394 if (isSolid) {
327395 final SolidPixelHiker hiker = SolidPixelHiker (
328396 offsets: offsets,
0 commit comments