import 'package:flutter/material.dart';

extension TextExt on Text {
  Size get size {
    final textPainter = TextPainter(
      text: TextSpan(text: data, style: style),
      maxLines: 1,
      textDirection: TextDirection.ltr,
    )..layout(minWidth: 0, maxWidth: double.infinity);
    return textPainter.size;
  }
}

/// Returns the first non-empty (after trim) entry, or '' if none match.
String firstNonEmpty(List<String?> values) {
  for (final v in values) {
    if (v != null && v.trim().isNotEmpty) return v;
  }
  return '';
}
