createSwatchWithGeometry method

Future<ArcGISImage> createSwatchWithGeometry(
  1. {required double screenScale,
  2. required Size size,
  3. required Geometry geometry,
  4. Color backgroundColor = Colors.transparent}
)

Creates a swatch image using the provided geometry, width, height, screen scale, and optional background color.

Parameters:

  • screenScale — The number of pixels per DIP (sometimes referred to as screen density or device pixel ratio). This value is used to scale symbology when rendering the swatch. The value should be set appropriately in order to render swatches at the correct scale for a given display. Note: Picture marker symbols without a set width or height are not scaled by screen scale, as unset width and height are taken to mean "render at native pixel scale".
  • size — The size of the swatch in device-independent pixels (DIPs).
  • geometry — The geometry of the symbol to be drawn in the swatch image. The specified geometry is in DIPs, with the point {0,0} located at the center of the swatch image. The X-axis increases towards the right side of the swatch image. The Y-axis increases towards the top of the swatch image. For example: when creating a swatch for a MarkerSymbol, specifying a geometry of {10,10} will draw the marker 10 DIPs up and to the right of the center of the swatch. The geometry type (ArcGISPoint, Polyline, Polygon) should correspond to the symbol type (MarkerSymbol, LineSymbol, FillSymbol). The geometry's spatial reference is ignored.
  • backgroundColor — The background color of the swatch. Can be null, in which case a transparent background is used.

Return Value: A Future. An ArcGISImage is returned asynchronously by the task. A null is returned if an error occurs or if the symbol is a 3D-specific symbol such as ModelSceneSymbol or MultilayerMeshSymbol.

Implementation

Future<ArcGISImage> createSwatchWithGeometry(
    {required double screenScale,
    required Size size,
    required Geometry geometry,
    Color backgroundColor = Colors.transparent}) {
  final coreBackgroundColor = backgroundColor.toArcGIS();
  final taskHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_Symbol_createSwatchWithGeometryCombined(
        _handle,
        screenScale,
        size,
        geometry._handle,
        coreBackgroundColor._handle,
        errorHandler);
  });
  return taskHandle.toFuture((element) => element.getValueAsArcGISImage()!);
}