I'm writing a unit or integration test for Flutter. Can I get the text, or other attributes of a widget, once I find it?
Yes, WidgetTester provides multiple methods for probing into the UI tree (widgets, states, elements, render objects). Here's an example of how you can use it to read out the text out of a Text widget:
tester.widget(find.byType(Text)).data;
See also https://flutter.io/testing/#widget-testing, which explains how to write widget tests in Flutter.
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