helpers.dart 558 B

1234567891011121314151617181920212223
  1. import 'package:flutter/widgets.dart';
  2. Size textSize(Text text) {
  3. var span = text.textSpan ?? TextSpan(text: text.data, style: text.style);
  4. var tp = TextPainter(
  5. text: span,
  6. textAlign: text.textAlign ?? TextAlign.start,
  7. textDirection: text.textDirection ?? TextDirection.ltr,
  8. textScaleFactor: text.textScaleFactor ?? 1,
  9. maxLines: text.maxLines,
  10. locale: text.locale,
  11. strutStyle: text.strutStyle,
  12. );
  13. tp.layout();
  14. return Size(tp.width, tp.height);
  15. }
  16. bool isMonospace(List<String> fontFamily) {
  17. return true; // TBD
  18. }