createSwatch method

Future<ArcGISImage> createSwatch({
  1. required double screenScale,
  2. double width = 0,
  3. double height = 0,
  4. Color backgroundColor = Colors.transparent,
})

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

This method will scale the symbol up or down in order to fit it in to the desired width and height of the swatch.

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".
  • width — The width of the swatch in device-independent pixels (DIPs).
  • height — The height of the swatch in device-independent pixels (DIPs).
  • 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> createSwatch({
  required double screenScale,
  double width = 0,
  double height = 0,
  Color backgroundColor = Colors.transparent,
}) {
  final coreBackgroundColor = backgroundColor.toArcGIS();
  final taskHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_Symbol_createSwatchCombined(
      _handle,
      screenScale,
      width,
      height,
      coreBackgroundColor._handle,
      errorHandler,
    );
  });
  return taskHandle.toFuture(
    (element) => element.getValueAsArcGISImage()!,
  );
}