패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.2

render_metrics

위젯 메트릭을 얻기 위한 라이브러리입니다. RenderObject를 사용하여 화면 창에 대한 위젯의 크기와 위치, 그리고 위젯 간의 차이를 가져옵니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
511
좋아요
122
Pub 점수
150

패키지 설치

flutter pub add render_metrics

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

render_metrics 패키지는 Flutter 애플리케이션 내 위젯에 대한 정확한 레이아웃 메트릭을 검색할 수 있는 방법을 제공합니다. RenderObject를 활용하여 개발자는 위젯의 정확한 크기 및 화면 위치 데이터를 얻을 수 있으며, 위젯 상태 간의 차이를 측정할 수도 있습니다. 이는 레이아웃 문제 디버깅, 사용자 정의 애니메이션 구현 또는 특정 UI 요소와 일치하는 오버레이 요소 생성에 특히 유용합니다. 이 라이브러리는 Android, iOS, 웹, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원합니다.

사용 사례

  • 디버깅 위젯 위치
  • 동적 오버레이 만들기
  • 레이아웃 변경 측정
  • 사용자 정의 애니메이션 구현
  • UI 성능 분석

주요 기능

  • 위젯 크기 및 화면 위치에 대한 액세스
  • 시간에 따른 위젯 메트릭 비교
  • 크로스 플랫폼 호환성
  • 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.