搜索插件、代码仓与 APP 分类

插件详情v1.0.0

measured_size

一个在运行时计算其子项大小的 Flutter 小部件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1120
喜欢数
40
Pub 分数
140

安装插件

flutter pub add measured_size

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

measured_size 包是一个 Flutter 小部件,可在运行时动态计算并暴露其子小部件的大小。它包装一个子小部件,并提供其实际渲染的尺寸,这在基于实时测量进行布局调整时非常有用。当构建需要精确尺寸的响应式或自适应 UI 时,这一点尤其有帮助。该包可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上正常工作。

适合场景

  • 响应式布局
  • 动态UI尺寸
  • 布局调试
  • 自适应设计
  • 运行时维度跟踪

主要特点

  • 实时尺寸测量
  • 跨平台支持
  • 简单 API
  • 子部件包装
  • 尺寸回调

适合对象

  • 需要动态布局逻辑的开发人员
  • 需要精确尺寸的UI构建工具
  • 调试布局问题
  • 自定义小部件创建

使用建议

  • 如果过度使用,可能会影响性能
  • 需要在 widget 树中谨慎放置
  • 不适用于静态布局
  • 仅限测量直接子项大小
  • 布局重建的潜在风险

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

measured_size

A flutter widget that calculates the size of it's child in runtime.

Getting Started

MeasuredSize Calculated the size of it's child in runtime. All you have to do is to wrap your widget with MeasuredSize and listen to size changes.

Usage

Complete example

MeasuredSize(
              onChange: (Size size) {
                setState(() {
                  print(size);
                });
              },
              child: Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            );

onChange will be called when the [Size] changes.

onChange will return the value ONLY once if it didn't change, and it will NOT return a value if it's equals to Size.zero

所属分类

源码仓库

使用此插件的项目

暂无相关数据。