diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 5add0444e9..24488c66d6 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -5577,6 +5577,9 @@ class RichText extends MultiChildRenderObjectWidget { properties.add(IntProperty('maxLines', maxLines, ifNull: 'unlimited')); properties.add(EnumProperty('textWidthBasis', textWidthBasis, defaultValue: TextWidthBasis.parent)); properties.add(StringProperty('text', text.toPlainText())); + properties.add(DiagnosticsProperty('locale', locale, defaultValue: null)); + properties.add(DiagnosticsProperty('strutStyle', strutStyle, defaultValue: null)); + properties.add(DiagnosticsProperty('textHeightBehavior', textHeightBehavior, defaultValue: null)); } } diff --git a/packages/flutter/test/widgets/rich_text_test.dart b/packages/flutter/test/widgets/rich_text_test.dart index 2486b9a9e1..b97312fddc 100644 --- a/packages/flutter/test/widgets/rich_text_test.dart +++ b/packages/flutter/test/widgets/rich_text_test.dart @@ -80,4 +80,42 @@ void main() { expect(tester.getSize(find.byType(IntrinsicHeight)).height, 3 * 16); }); + + testWidgets('RichText implements debugFillProperties', (WidgetTester tester) async { + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); + RichText( + text: const TextSpan(text: 'rich text'), + textAlign: TextAlign.center, + textDirection: TextDirection.rtl, + softWrap: false, + overflow: TextOverflow.ellipsis, + textScaleFactor: 1.3, + maxLines: 1, + locale: const Locale('zh', 'HK'), + strutStyle: const StrutStyle( + fontSize: 16, + ), + textWidthBasis: TextWidthBasis.longestLine, + textHeightBehavior: const TextHeightBehavior(applyHeightToFirstAscent: false), + ).debugFillProperties(builder); + + final List description = builder.properties + .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info)) + .map((DiagnosticsNode node) => node.toString()) + .toList(); + + expect(description, [ + 'textAlign: center', + 'textDirection: rtl', + 'softWrap: no wrapping except at line break characters', + 'overflow: ellipsis', + 'textScaleFactor: 1.3', + 'maxLines: 1', + 'textWidthBasis: longestLine', + 'text: "rich text"', + 'locale: zh_HK', + 'strutStyle: StrutStyle(size: 16.0)', + 'textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false, applyHeightToLastDescent: true)' + ]); + }); }