toDrawable method Null safety

  1. @override
Widget toDrawable(
  1. {Color? fillColor,
  2. Color? borderColor,
  3. double borderStrokeWidth = 3,
  4. bool isDotted = false,
  5. bool prettyPaint = true,
  6. StrokeCap strokeCap = StrokeCap.round,
  7. StrokeJoin strokeJoin = StrokeJoin.round,
  8. List<Color>? gradientColors,
  9. List<double>? colorsStop}
)
override

Create a drawable area for a FlutterMap out of this region

prettyPaint controls what type of shape will be output. If false, multiple overlapping rectangular Polygons will be output, representing the area that will actually be downloaded. If true (default), a Polyline will be output, which handles all the nice rounding and some other stuff that makes it more suitable to present to the user.

Some parameters will only have an effect depending whether a Polygon or Polyline is being output.

Returns a layer to be added to the layer property of a FlutterMap.

Implementation

@override
Widget toDrawable({
  Color? fillColor,
  Color? borderColor,
  double borderStrokeWidth = 3,
  bool isDotted = false,
  bool prettyPaint = true,
  StrokeCap strokeCap = StrokeCap.round,
  StrokeJoin strokeJoin = StrokeJoin.round,
  List<Color>? gradientColors,
  List<double>? colorsStop,
}) =>
    prettyPaint
        ? PolylineLayer(
            polylines: [
              Polyline(
                points: line,
                strokeWidth: radius,
                useStrokeWidthInMeter: true,
                color: fillColor ?? const Color(0x00000000),
                borderColor: borderColor ?? const Color(0x00000000),
                borderStrokeWidth: borderStrokeWidth,
                isDotted: isDotted,
                gradientColors: gradientColors,
                colorsStop: colorsStop,
                strokeCap: strokeCap,
                strokeJoin: strokeJoin,
              ),
            ],
          )
        : PolygonLayer(
            polygons: toOutlines(1)
                .map(
                  (rect) => Polygon(
                    points: rect,
                    isFilled: fillColor != null,
                    color: fillColor ?? Colors.transparent,
                    borderColor: borderColor ?? const Color(0x00000000),
                    borderStrokeWidth: borderStrokeWidth,
                    isDotted: isDotted,
                    strokeCap: strokeCap,
                    strokeJoin: strokeJoin,
                  ),
                )
                .toList(),
          );