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

插件详情v0.5.0

responsive_layout_builder

基于屏幕尺寸和方向构建响应式布局的 Flutter 包。支持腕表、小型/中型/大型移动设备、小型/大型平板或桌面设备。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
139
喜欢数
24
Pub 分数
140

安装插件

flutter pub add responsive_layout_builder

插件介绍

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

一个 Flutter 包,通过检测屏幕尺寸和方向来简化响应式布局的创建,适用于腕表、手机、平板和桌面设备。它提供了一个简洁的 API,可根据当前设备的特性动态调整 UI 组件,确保在各种设备形态上都能提供一致的用户体验。该包非常适合希望构建灵活、可扩展界面而无需编写重复媒体查询逻辑的开发者。

适合场景

  • 为不同屏幕尺寸调整用户界面
  • 使用一致的设计构建跨平台应用
  • 为手表和平板电脑创建布局
  • 无需手动媒体查询的响应式设计
  • 优化桌面和移动布局
  • 支持多种设备方向

主要特点

  • 自动屏幕尺寸检测
  • 面向方向的布局调整
  • 支持手表、手机、平板电脑和台式机
  • 简单、声明式 API
  • 针对常见设备的内置断点
  • 跨平台兼容性

适合对象

  • 开发多设备应用程序的开发者
  • 注重响应式设计的团队
  • 需要自适应UI的项目
  • Flutter 初学者学习响应式布局
  • 同时面向移动和桌面用户的App
  • 具有复杂布局需求的项目

使用建议

  • 可能需要在多种设备类型上进行测试
  • 断点是预定义的,无法完全自定义
  • 对非常频繁重建的性能影响
  • 受限于屏幕尺寸和方向检测
  • 不处理动态内容调整大小
  • 最适合与状态管理配合使用,以实现复杂布局

原始 README

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

responsive_layout_builder

Flutter package for building responsive layout based on screen sizes and orientation. It could be wristwatch, small/medium/large mobile, small/large tablet or desktop.

Getting Started

Widget approach

ResponsiveLayoutBuilder could be used as usual widget builder such as LayoutBuilder or OrientationBuilder, etc.

ResponsiveLayoutBuilder(
    builder: (context, screenSize) {
        // Use size argument to build size dependent widgets
    },
),

size property within screenSize stores LayoutSize which could be watch, mobile, tablet, desktop or tv.

mobile property within screenSize stores MobileLayoutSize which could be small, medium or large.

tablet property within screenSize stores TabletLayoutSize which could be small or large.

Functional approach

For using functional approach to retrieve current size use following:

// for getting mobile layout size 
getMobileLayoutSize(width: MediaQuery.of(context).size.width);

// for getting tablet layout size 
getTabletLayoutSize(width: MediaQuery.of(context).size.width);

// for getting screen size based on width
getScreenSize(width: MediaQuery.of(context).size.width);

// for getting screen size based on context 
getContextualScreenSize(context: context);

If you need to specify ScreenSizeSettings for all above functions sizes argument is needed to be passed, like this:

sizes: ScreenSizeSettings(...)

For getScreenSize and getContextualScreenSize could be specified also orientation and defaultSize.

TODO

  • Figure out how to determine TV
  • Add tests

所属分类

依赖

依赖清单 1 项

  • pedantic^1.11.0

源码仓库

使用此插件的项目

暂无相关数据。