From cad08149caf3316aca5733a9b5af01c3299664b5 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Tue, 11 Feb 2020 19:08:05 -0500 Subject: [PATCH] Remove invalid assert for TextHeightBehavior (#50603) --- packages/flutter/lib/src/painting/text_painter.dart | 1 - packages/flutter/test/painting/text_painter_test.dart | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index cdfeb78ad9..a615c64892 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -346,7 +346,6 @@ class TextPainter { ui.TextHeightBehavior get textHeightBehavior => _textHeightBehavior; ui.TextHeightBehavior _textHeightBehavior; set textHeightBehavior(ui.TextHeightBehavior value) { - assert(value != null); if (_textHeightBehavior == value) return; _textHeightBehavior = value; diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index 50f8e1bf3f..46f1d43bec 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -730,6 +730,15 @@ void main() { expect(painter.inlinePlaceholderBoxes[13], const TextBox.fromLTRBD(351, 30, 401, 60, TextDirection.ltr)); }, skip: isBrowser); + // Null values are valid. See https://github.com/flutter/flutter/pull/48346#issuecomment-584839221 + test('TextPainter set TextHeightBehavior null test', () { + final TextPainter painter = TextPainter(textHeightBehavior: null) + ..textDirection = TextDirection.ltr; + + painter.textHeightBehavior = const TextHeightBehavior(); + painter.textHeightBehavior = null; + }); + test('TextPainter line metrics', () { final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr;