Testing text in TextSpan. In addition to Rémi’s answer, here is the way to find the text from a RichText. You set the key to the RichText and then you can do:
1 2 3 4 5 6 7 8 9 10 | Finder widgetFinder = find.byKey(key); Finder rtFinder = find.descendant(of: widgetFinder, matching: find.byType(RichText)); RichText richText = rtFinder.evaluate().first.widget as RichText; String richTextText = richText.text.toPlainText(); print('Text from Text widget: $richTextText'); expect(richTextText, 'This is my text', reason: 'Text from found text widget do not match'); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.