If we have a TextSpan
that is a child of a RichText
widget, how would you test the text content.
new TextSpan(
text: 'Hello world!',
style: new TextStyle(color: Colors.black),
)
In your tests, with a Text
widget, you can use expect(find.text('Hello world!'), findsOneWidget)
, but this doesn't work if you have a TextSpan
.
expect(find.byType(TextSpan), findsOneWidget)
also does not find any widgets of type TextSpan
.
The <span> tag is an inline container used to mark up a part of a text, or a part of a document. The <span> tag is easily styled by CSS or manipulated with JavaScript using the class or id attribute.
That's not possible. As TextSpan
doesn't actually render anything.
It is data information used by another object to actually render something.
What you can do instead is to find the widget to which you pass your TextSpan
. And then verify it's correct
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With