Library for getting widget metrics. Uses RenderObject to get the size and position of widgets relative to the screen window, as well as the difference between widgets.
Package selection guidance compiled from public package information, community data, and project usage.
The render_metrics package provides a way to retrieve precise layout metrics for widgets in Flutter applications. By leveraging RenderObject, it enables developers to obtain accurate size and screen position data for widgets, as well as measure differences between widget states. This is particularly useful for debugging layout issues, implementing custom animations, or creating overlay elements that align with specific UI components. The library supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux.
Use cases
Debugging widget positioning
Creating dynamic overlays
Measuring layout changes
Implementing custom animations
Analyzing UI performance
Key features
Access to widget size and screen position
Comparison of widget metrics over time
Cross-platform compatibility
Integration with RenderObject
Lightweight and focused API
Suitable for
UI debugging tools
Custom layout utilities
Animation frameworks
Developer tooling
Performance analysis
Considerations
Requires access to RenderObject context
May impact performance if used excessively
Not suitable for runtime metrics in high-frequency scenarios
Limited to visible widgets during rendering
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Get a bundle with the positioning coordinates of the wrapped widget.
RenderData data = renderManager.getRenderData("uniqueWidgetId");
Calculating the difference in positioning between two widgets
Wrap the widgets you want to compare in RenderMetricsObjects. Specify two different ids for each of them. Please note, that the manager parameter of both widgets should contain the link to the same RenderParametersManager instance.
Specify two unique widget identifiers when using the getDiffById() function and extract a bundle with the relative difference in positioning coordinates between the widgets.
RenderData instance contains a complete set of properties that characterize any widget in a two-dimensional space.
All metrics positioning coordinates are global, meaning they are relative to the entire screen coordinate space.
RenderData also provides you an ability to get all widget keypoint XY-coordinates by calling one of special getters.
ComparisonDiff
You can get the comparison relative results for each widget keypoint from the ComparisonDiff instance.
An additional set of special getters can help you calculate the difference between two adjacent sides of two different widgets (e.g. right to left, top to bottom, etc.).
Installation
Add render_metrics to your pubspec.yaml file:
dependencies:render_metrics:$currentVersion$
At this moment, the current version of render_metrics is .
Changelog
All notable changes to this project will be documented in this file.
Issues
To report your issues, submit them directly in the Issues section.
Contribute
If you would like to contribute to the package (e.g. by improving the documentation, fixing a bug or adding a cool new feature), please read our contribution guide first and send us your pull request.
Your PRs are always welcome.
How to reach us
Please feel free to ask any questions about this package. Join our community chat on Telegram. We speak English and Russian.