flutter_widget_tree 1.0.0
flutter_widget_tree: ^1.0.0 copied to clipboard
A CLI tool to extract and visualize Flutter widget tree structure from Dart files.
🧩 Flutter Tree #
A command-line tool that parses Dart files and extracts the widget hierarchy from Flutter widget classes (StatelessWidget and StatefulWidget).
It analyzes build() methods and prints a structured widget tree.
🚀 Features #
- Parses Dart files to identify widget classes.
- Extracts
build()methods and identifies root widgets. - Supports nested
childandchildrenwidgets. - CLI interface to analyze any Dart file.
- Clean, readable output with emoji indicators.
- Shows widget relationships in tree format.
📦 Installation #
Prerequisites #
- Dart SDK installed
Option 1: Install via Pub (Recommended) #
dart pub global activate flutter_tree
Run the Tool #
flutter_tree
Option 2: Clone the Repo #
git clone https://github.com/vanshbhardwajhere/flutter_tree.git
cd flutter_tree
Run the Tool #
dart run bin/flutter_tree.dart
📝 Usage #
📄 Enter the full path to the Dart file: path/to/your/file.dart
The CLI will analyze the file and output something like:
🔍 Visiting widget class: MyHomePage
✅ Found build() method for MyHomePage
🔄 Return is a method call: Scaffold
📦 Widget Tree Summary for: path/to/your/file.dart
└── Widget: MyHomePage
└── Widget: Scaffold
└── Widget: AppBar
└── Widget: Body
📁 Example #
Use the provided sample Dart file in /test/sample.dart to test the tool.
👨💻 Author #
Vansh
📧 Email: vanshbhardwajhere@gmail.com
📜 License #
This project is open source and available under the MIT License.