How to extract flutter/dart parse tree?

Viewed 97

how to extract all the relations between classes from a flutter file?

for example, in the below code, The desired output should be

1- I have widget RotationTransition

2- RotationTransition has one child of type Stack

3- Stack has children (Positioned, Center)

4- Positioned has a child of type FlutterLogo

5- Center has one child of type FlutterLogo

(It would be better if it's represented in tree form :D) any ideas How can I get such output?

RotationTransition(
        turns: animation,
        child: Stack(
          children: [
            Positioned.fill(
              child: FlutterLogo(),
            ),
            Center(
              child: Text(
                'Click me!',
                style: TextStyle(
                  fontSize: 60.0,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
      ),
2 Answers

You can use Dart DevTools. It provides all the widget tree like below.

enter image description here

You can use dart tools if you are using VSCode enter image description here click on this icon to open dart and than this will open

enter image description here

here all the widgets will be shown in tree form with there details too

Related