From e18c34abbbbfc0cd84e087294bd26bfc6ba516bd Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 13 Sep 2022 17:38:06 -0700 Subject: [PATCH] Fix text direction nullability (#111513) --- packages/flutter/lib/src/painting/text_painter.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 81c45e34c5c..0c893ecd467 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -222,11 +222,13 @@ class TextPainter { /// This is a convenience method that creates a text painter with the supplied /// parameters, lays it out with the supplied [minWidth] and [maxWidth], and /// returns its [TextPainter.width] making sure to dispose the underlying - /// resources. + /// resources. Doing this operation is expensive and should be avoided + /// whenever it is possible to preserve the [TextPainter] to paint the + /// text or get other information about it. static double computeWidth({ required InlineSpan text, + required TextDirection textDirection, TextAlign textAlign = TextAlign.start, - TextDirection? textDirection, double textScaleFactor = 1.0, int? maxLines, String? ellipsis, @@ -262,11 +264,13 @@ class TextPainter { /// This is a convenience method that creates a text painter with the supplied /// parameters, lays it out with the supplied [minWidth] and [maxWidth], and /// returns its [TextPainter.maxIntrinsicWidth] making sure to dispose the - /// underlying resources. + /// underlying resources. Doing this operation is expensive and should be avoided + /// whenever it is possible to preserve the [TextPainter] to paint the + /// text or get other information about it. static double computeMaxIntrinsicWidth({ required InlineSpan text, + required TextDirection textDirection, TextAlign textAlign = TextAlign.start, - TextDirection? textDirection, double textScaleFactor = 1.0, int? maxLines, String? ellipsis,