tryToGetChildSize method

void tryToGetChildSize()

Attempts to get the _childWidth and _childHeight of the child to be wrapped with a dashed line.

Implementation

void tryToGetChildSize() {
  WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) {
    try {
      final RenderBox? box = _childKey.currentContext?.findRenderObject() as RenderBox?;
      final double tempWidth = box?.size.width ?? 0.0;
      final double tempHeight = box?.size.height ?? 0.0;
      final bool needUpdate = tempWidth != _childWidth || tempHeight != _childHeight;
      if (needUpdate) {
        setState(() {
          _childWidth = tempWidth;
          _childHeight = tempHeight;
        });
      }
    } catch (e) {
      debugPrint(e.toString());
    }
  });
}