createSymbol method

Widget createSymbol(
  1. BuildContext context,
  2. LegendEntry legendEntry,
  3. TappableLegend legend,
  4. bool isHidden,
)

Implementation

Widget createSymbol(BuildContext context, common.LegendEntry legendEntry,
    TappableLegend legend, bool isHidden) {
  // TODO: Consider allowing scaling the size for the symbol.
  // A custom symbol renderer can ignore this size and use their own.
  final materialSymbolSize = new Size(12.0, 12.0);

  final entryColor = legendEntry.color;
  final color = entryColor == null ? null : ColorUtil.toDartColor(entryColor);

  // Get the SymbolRendererBuilder wrapping a common.SymbolRenderer if needed.
  final SymbolRendererBuilder symbolRendererBuilder =
      legendEntry.symbolRenderer! is SymbolRendererBuilder
          ? legendEntry.symbolRenderer! as SymbolRendererBuilder
          : new SymbolRendererCanvas(
              legendEntry.symbolRenderer!, legendEntry.dashPattern);

  return new GestureDetector(
      child: symbolRendererBuilder.build(
        context,
        size: materialSymbolSize,
        color: color,
        enabled: !isHidden,
      ),
      onTapUp: makeTapUpCallback(context, legendEntry, legend));
}