搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.2

render_metrics

用於取得組件度量的程式庫。使用 RenderObject 取得相對於螢幕視窗的小部件大小與位置,以及小部件之間的差異。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
511
喜歡數
122
Pub 分數
150

安裝套件

flutter pub add render_metrics

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

render_metrics 套件提供了一種方法,可於 Flutter 應用程式中取得組件的精確佈局指標。透過利用 RenderObject,它讓開發者能夠取得組件的準確大小與螢幕位置資料,以及測量組件狀態之間的差異。這對於除錯佈局問題、實作自訂動畫,或建立與特定 UI 元件對齊的覆疊元素特別有用。該函式庫支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。

適用情境

  • 除錯小工具定位
  • 建立動態覆蓋層
  • 測量佈局變更
  • 實現自定義動畫
  • 分析UI效能

主要特色

  • 存取元件大小與螢幕位置
  • 隨時間變化的 widget 指標比較
  • 跨平台相容性
  • 與 RenderObject 的整合
  • 輕量且專注的 API

適合對象

  • UI 調試工具
  • 自訂佈局工具
  • 動畫框架
  • 開發者工具
  • 效能分析

使用建議

  • 需要存取 RenderObject 上下文
  • 如果過度使用,可能會影響效能
  • 不適用於高頻率情境下的執行時間指標
  • 渲染期間僅限可見小部件

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Render Metrics

Made by Surf 🏄‍♂️🏄‍♂️🏄‍♂️

Build Status Coverage Status Pub Version Pub Likes Pub popularity Flutter Platform

Overview

This package helps retrieve the current positioning coordinates of any widget in a widgets tree in your Flutter application.

Currently supported features

  • Retrieve the full set of positioning coordinates of the desired widget at any time;
  • Calculate the difference in positioning between two widgets and use it the way you need.

Example

Getting widget's coordinates

Instantiate RenderParametersManager object. You can set a special type for the widget's unique identifier or leave it dynamic.

final renderManager = RenderParametersManager<dynamic>();

Wrap the desired widget in a RenderMetricsObject. The id parameter is the widget’s unique identifier.

RenderMetricsObject(
    id: "uniqueWidgetId",
    manager: renderManager,
    child: Container(
        ...
    ),
),

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.

RenderMetricsObject(
    id: "rowWidgetId",
    manager: renderManager,
    child: Row(
        ...
    ),
),
RenderMetricsObject(
    id: "columnWidgetId",
    manager: renderManager,
    child: Column(
        ...
    ),
),

Specify two unique widget identifiers when using the getDiffById() function and extract a bundle with the relative difference in positioning coordinates between the widgets.

ComparisonDiff diff =
    renderManager.getDiffById("rowWidgetId", "columnWidgetId");

What metrics can I get?

RenderData

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

RenderData also provides you an ability to get all widget keypoint XY-coordinates by calling one of special getters.

RenderData

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.).

RenderData

Installation

Add render_metrics to your pubspec.yaml file:

dependencies:
  render_metrics: $currentVersion$

At this moment, the current version of render_metrics is render_metrics version.

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.

Telegram

License

Apache License, Version 2.0

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。