How to get a BuildContext from WidgetTester?

Viewed 242

When doing a Flutter widget test, I can get a context from the WidgetTester if I know something about at least one widget in the tree. E.g., if I know there's a Text widget in the test widget tree, I can

BuildContext context = tester.element(find.byType(Text));

How can I get a context more generally? E.g., can I get the root widget of the tree and get its BuildContext?

0 Answers
Related