搜索分类、插件与代码仓

插件详情v0.2.1

smart_grid_view

一个响应式网格视图,其交叉轴子项数量会根据可用的水平尺寸进行调整。

近 30 天下载
15
喜欢数
16
Pub 分数
30

安装插件

flutter pub add smart_grid_view

插件介绍

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

SmartGridView 是一个适用于 Flutter 的响应式网格布局小部件,它会根据可用的水平空间自动调整交叉轴上的子项数量。通过动态改变列数,确保屏幕宽度得到最佳利用,非常适合在不同设备尺寸上实现自适应 UI。该包简化了响应式设计,无需复杂的媒体查询或自定义逻辑。它可无缝集成到现有的 Flutter 项目中,并支持网格项的流畅渲染。

适合场景

  • 多屏幕尺寸的响应式布局
  • 自适应网格设计适用于移动设备和平板电脑
  • 动态内容网格,项目宽度可变
  • 构建灵活的产品或图像画廊
  • 创建可扩展的仪表板界面

主要特点

  • 自动交叉轴子项数量调整
  • 基于可用宽度的响应式行为
  • 与 Flutter 的 GridView 简单集成
  • 支持自定义间距和对齐
  • 针对大型数据集优化的性能

适合对象

  • 开发响应式应用的开发者
  • 需要自适应网格布局的设计师
  • 面向多种设备形态的项目
  • 包含动态或可变内容的应用程序

使用建议

  • 仅限交叉轴响应式(非行基)
  • 可能需要针对复杂的物品尺寸进行调整
  • 最适合统一或可预测的物品尺寸
  • 不太适合高度自定义的网格图案
  • 性能取决于物品的复杂性和数量

原始 README

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

smart_grid_view

A responsive grid view that changes it's cross axis child count based on the available horizontal size.

This widget is great for creating responsive designs as the sized of tiles stays about the same across different screen sizes.

How does it work

Using the width of tiles, SmartGridview will calculate the crossAxisCount for the underlying GridView with maxWidth ~/ tileWidth.

The tileHeight is used with tileWidth to calculate gridChildRatio.

Example

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Example')),
        body: SmartGridView(
          tileWidth: 128,
          tileHeight: 168,
          children: List.generate(80, (index) => Card(
            child: GridTile(
              child: Text('tile #$index'),
            ),
          )),
        ),
      ),
    );
  }
}
Result

所属分类

源码仓库

使用此插件的项目

暂无相关数据。