updateStoredDimensions method

void updateStoredDimensions(
  1. double newHeight,
  2. double newWidth
)

Implementation

void updateStoredDimensions(double newHeight, double newWidth) {
  double? oldHeight = _widgetDimensions[widget.valueKey]?.height;
  double? oldWidth = _widgetDimensions[widget.valueKey]?.width;
  if (oldHeight == newHeight && oldWidth == newWidth) {
    // Backend-gated: re-show the widget when native re-sends the same (valid) dimensions.
    if (_shouldSetVisibleOnSameDimensions && !visible && newHeight > 0 && newWidth > 0) {
      setState(() {
        visible = true;
      });
    }
    return;
  }

  _widgetDimensions[widget.valueKey] = Size(newWidth, newHeight);
  if (_specLayout == null) {
    Plotline.plotlineDebugLog(newHeight > 0 && newWidth > 0
        ? "PlotlineFlutterRender: NATIVE ${widget.valueKey} ${newWidth.toInt()}x${newHeight.toInt()} (platform view)"
        : "PlotlineFlutterRender: EMPTY ${widget.valueKey} (nothing to show)");
  }

  setState(() {
    height = newHeight;
    width = newWidth;
    if (height > 0 && width > 0) {
      visible = true;
    } else {
      visible = false;
    }
  });
}