calcSize method

  1. @override
Size? calcSize(
  1. BuildContext context, {
  2. double spacing = 0,
  3. Axis orientation = Axis.horizontal,
  4. T? param,
})
override

Implementation

@override
Size? calcSize(
  BuildContext context, {
  double spacing = 0,
  Axis orientation = Axis.horizontal,
  T? param,
}) {
  final w = _width ?? 0;
  final h = _height ?? 0;

  if (w > 0 && h > 0) {
    if (orientation == Axis.horizontal) {
      return Size(w + spacing, h);
    } else {
      return Size(w, h + spacing);
    }
  } else {
    final theme = Theme.of(context);

    final size = getTextSize(
      text(param ?? toolValue?.value) ?? '',
      style: textStyle ??
          TextStyle(
            color: fontColor ?? theme.colorScheme.onSurface,
            fontSize: fontSize,
          ),
    );
    final options = this.options(param);
    final extraWidth = 24 /* extra padding for TextButton */ +
        (iconSize ?? 0) +
        (options != null && options.isNotEmpty ? 24 : 0);

    if (orientation == Axis.horizontal) {
      return Size(size.width + extraWidth + spacing, size.height);
    } else {
      return Size(size.width + extraWidth, size.height + spacing);
    }
  }
}