File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -664,7 +664,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
664664 final DefaultTextStyle defaultTextStyle = DefaultTextStyle .of (context);
665665 TextStyle ? effectiveTextStyle = widget.style;
666666 if (effectiveTextStyle == null || effectiveTextStyle.inherit) {
667- effectiveTextStyle = defaultTextStyle.style.merge (widget.style);
667+ effectiveTextStyle = defaultTextStyle.style.merge (widget.style ?? _controller._textSpan.style );
668668 }
669669 if (MediaQuery .boldTextOverride (context)) {
670670 effectiveTextStyle = effectiveTextStyle.merge (const TextStyle (fontWeight: FontWeight .bold));
Original file line number Diff line number Diff line change @@ -5052,4 +5052,24 @@ void main() {
50525052 expect (find.text ('Regular Text' , skipOffstage: false ), findsOneWidget);
50535053 expect (find.byType (SelectableText , skipOffstage: false ), findsOneWidget);
50545054 });
5055+
5056+ testWidgets ('SelectableText text span style is merged with default text style' , (WidgetTester tester) async {
5057+ // This is a regression test for https://github.com/flutter/flutter/issues/71389
5058+
5059+ const TextStyle textStyle = TextStyle (color: Color (0xff00ff00 ), fontSize: 12.0 );
5060+
5061+ await tester.pumpWidget (
5062+ const MaterialApp (
5063+ home: SelectableText .rich (
5064+ TextSpan (
5065+ text: 'Abcd' ,
5066+ style: textStyle,
5067+ ),
5068+ ),
5069+ ),
5070+ );
5071+
5072+ final EditableText editableText = tester.widget (find.byType (EditableText ));
5073+ expect (editableText.style.fontSize, textStyle.fontSize);
5074+ });
50555075}
You can’t perform that action at this time.
0 commit comments