resolve method

List<ResolvedShapeContent> resolve(
  1. ShapeElement source,
  2. Map<String, double> bands
)

Resolves every content layer. Repeating the call for the same source and bands, as fitting followed by publication does, reuses the last result.

Implementation

List<ResolvedShapeContent> resolve(
  ShapeElement source,
  Map<String, double> bands,
) {
  if (_last case final last?
      when identical(last.source, source) && identical(last.bands, bands)) {
    return last.contents;
  }
  final contents = List<ResolvedShapeContent>.unmodifiable([
    for (final layer
        in definition.expandedLayers.whereType<ShapeContentLayerDefinition>())
      if (layer.bounds.resolve(source, textHeights: bands) case final bounds
          // A composition hides a region by collapsing it; its content is
          // kept in the story but neither laid out nor fitted.
          when bounds.width > 0 && bounds.height > 0)
        if (_sessions[layer.contentType]!.resolve(
              source: source,
              declaration: layer,
              bounds: bounds,
            )
            case final content?)
          _validate(content, layer),
  ]);
  _last = (source: source, bands: bands, contents: contents);
  return contents;
}