transformNodeFromIconButton function

void transformNodeFromIconButton(
  1. ButtonNode node
)

Implementation

void transformNodeFromIconButton(ButtonNode node) {
  final painter = TextPainter(
    text: TextSpan(
      text: node.properties.label,
      style: TextUtils.retrieveTextStyleFromProp(
        node.properties.labelStyle,
        effects: const [],
      ),
    ),
    textDirection: TextDirection.ltr,
    textAlign: node.properties.labelAlignment.toFlutter(),
  );
  painter.layout();
  double width =
      painter.width + ((node.properties.icon.size ?? kDefaultIconSize) * 2);
  if (node.properties.icon.show) {
    width +=
        ((node.properties.icon.size ?? kDefaultIconSize) + node.properties.gap);
  }
  double height = painter.height + (10 * 2);
  node.update(
    middleBoxLocal: node.basicBoxLocal.copyWith(
      width: width,
      height: height,
    ),
    padding: defaultButtonPadding,
  );
  node.properties.icon = node.properties.icon.copyWith(size: painter.height);
  node.aspectRatioLock = false;
}