Home > Enterprise >  Flutter: how get all properties for all widgets's objects in my flutter app by dart Code to use
Flutter: how get all properties for all widgets's objects in my flutter app by dart Code to use

Time:10-28

Flutter: how get all properties for all widgets's objects in my flutter app by dart Code to use it in Automated Testing ? I know exist three types from testing :

1. Unit tests.
2. Widget tests.
3. Integration tests.


But I just want to know all the details about each Widget and also Write it in a text file? for Example this image explain an example in Dev tool But I neet it by codeing
Thanks in advance

CodePudding user response:

In your tests you could use this code to access the properties of a widget in the current tree:

final FloatingActionButton fab = tester.widget(find.byType(FloatingActionButton));

expect(fab.tooltip, ...);

Here you tell the WidgetTester to find a widget in the current widget tree, when a widget is found you can access its properties.

Important, that your 'First A, Arrange' is correctly setup, thus a widget tree is build and the widget you're looking for is avaialable.

When you are searching for a more generic widget which occures more then once in the widget tree I suggest using the find.byKey method, like so:

tester.widget(find.byKey(Key('exampleKey')));

Ofcourse, the Finder widget has more than two methods, thus any of the other find methods could be used.

Greetz

  • Related