Biblioteca para obter métricas de widget. Usa o RenderObject para obter o tamanho e a posição dos widgets em relação à janela da tela, bem como a diferença entre os widgets.
Orientação gerada a partir de informações públicas. Apenas para referência.
O pacote render_metrics fornece uma maneira de recuperar métricas precisas de layout para widgets em aplicativos Flutter. Ao aproveitar o RenderObject, ele permite que desenvolvedores obtenham dados precisos de tamanho e posição na tela para widgets, bem como medidas de diferenças entre estados do widget. Isso é particularmente útil para depurar problemas de layout, implementar animações personalizadas ou criar elementos sobrepostos que se alinham a componentes específicos da IU. A biblioteca suporta todas as principais plataformas, incluindo Android, iOS, Web, macOS, Windows e Linux.
Casos de uso
Depuração de posicionamento de widget
Criando sobreposições dinâmicas
Medição de alterações de layout
Implementando animações personalizadas
Analisando o desempenho da interface
Principais recursos
Acesso ao tamanho do widget e posição na tela
Comparação de métricas de widget ao longo do tempo
Compatibilidade multiplataforma
Integração com RenderObject
API leve e focada
Indicado para
Ferramentas de depuração da interface do usuário
Ferramentas de layout personalizadas
frameworks de animação
Ferramentas para desenvolvedores
Análise de desempenho
Considerações
Requer acesso ao contexto RenderObject
Pode afetar o desempenho se usado excessivamente
Não adequado para métricas de tempo de execução em cenários de alta frequência
Limitado a widgets visíveis durante o renderização
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.