mergeDrawingParameters function

DrawingParameters mergeDrawingParameters(
  1. DrawingParameters childDrawingParameters,
  2. DrawingParameters? parentDrawingParameters
)

Use each property of childDrawingParameters in priority, and properties of parentDrawingParameters if not defined in child parameters. Note that it is allowed for a property that both definitions are null.

Implementation

DrawingParameters mergeDrawingParameters(
    DrawingParameters childDrawingParameters,
    DrawingParameters? parentDrawingParameters) {
  DrawingParameters usedDrawingParameters = DrawingParameters(
      fillColor: childDrawingParameters.fillColor ??
          parentDrawingParameters!.fillColor,
      strokeColor: childDrawingParameters.strokeColor ??
          parentDrawingParameters!.strokeColor,
      strokeWidth: childDrawingParameters.strokeWidth ??
          parentDrawingParameters!.strokeWidth,
      strokeLineCap: childDrawingParameters.strokeLineCap ??
          parentDrawingParameters!.strokeLineCap,
      strokeLineJoin: childDrawingParameters.strokeLineJoin ??
          parentDrawingParameters!.strokeLineJoin,
      strokeLineMiterLimit: childDrawingParameters.strokeLineMiterLimit ??
          parentDrawingParameters!.strokeLineMiterLimit,
      translate: childDrawingParameters.translate ??
          parentDrawingParameters!.translate,
      transformMatrixValues: childDrawingParameters.transformMatrix ??
          parentDrawingParameters!.transformMatrix);
  return usedDrawingParameters;
}