搜索分类、插件与代码仓

插件详情v1.1.0

design_grid

按照设计师的构想实现设计。可以使用经典的响应式网格布局方法,也可以选择 Material Design 布局。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
71
喜欢数
36
Pub 分数
160

安装插件

flutter pub add design_grid

插件介绍

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

Design Grid 是一个 Flutter 包,帮助开发者精确实现设计师的意图。它支持传统的响应式网格布局和 Material Design 的布局系统,为 UI 构建提供灵活性。通过直观的 API,简化了跨平台的对齐、间距和响应式行为。非常适合希望在设计原型和最终应用界面之间保持视觉一致性的团队。该包与所有主要的 Flutter 平台兼容,确保跨平台可靠性。

适合场景

  • 从 Figma 或 Sketch 实现像素级精确的设计
  • 为多种屏幕尺寸构建响应式布局
  • 将 Material Design 指南集成到自定义 UI 中
  • 在小部件之间创建一致的间距和对齐
  • 确保多平台应用中的设计保真度

主要特点

  • 支持经典响应式网格
  • 内置的 Material Design 布局支持
  • 跨平台兼容性
  • 灵活的间距和对齐工具
  • 与现有 Flutter 项目的轻松集成

适合对象

  • 与设计师紧密协作的前端开发人员
  • 注重设计准确性的团队
  • 需要在不同设备上保持一致 UI 的项目
  • 使用 Material Design 原则的开发者
  • 面向多个平台的应用程序

使用建议

  • 需要了解网格系统
  • 复杂布局可能需要额外的样式
  • 最好与设计系统文档配合使用
  • 不是完整的UI框架——补充现有控件
  • 超出网格结构的自定义功能有限

原始 README

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

Build Status

Implement designs just like in Figma. Arrange your widgets in a grid and make your designer happy.

Design Grid streamlines your workflow and saves time. Easily configure multiple devices and screen sizes while reducing boilerplate code. Its user-friendly design makes integration effortless, allowing you to focus on your project's core.

The classic use-case of implementing a colum-based design. Use ResponsiveDesignGrid to implement a bootstrap-like design system where every element has a different column-span based on breakpoints.

Need to implement a design based on the strict rules of Material Layout? Use the MaterialDesignGrid to get an exact implementation of the Material Design Layout guide.

🔗 Table of Contents

✨ Features

Responsive Design Grid

Implement a column-based design with different column-spans for every breakpoint. Responsive design grid widgets can be indefinitely nested. Create small and clean widgets that use ResponsiveDesignGrid for layout. They will fit, no matter how deeply nested you use them.

You can customize:

  • Breakpoints
  • Column-spacing
  • Row-spacing
  • Grid-padding
  • Amount of columns

Material Design Grid

Implement a design based on the Material Design guidelines. Material Design Grid is not meant to be used nested.

You can customize:

  • Breakpoints
  • Column-spacing
  • Row-spacing
  • Grid-padding
  • Amount of columns per breakpoint

🎉 Getting started

Decide whether you need to use the ResponsiveDesignGrid or the MaterialDesignGrid. Speak with your designer to build a common understanding.

🏗️ Usage

Responsive Design Grid

ResponsiveDesignGridConfig is required only once in your app, it provides the ResponsiveDesignGridTheme. You can however always add an extra ResponsiveDesignGridTheme widget if you really need to. Beware, that this is not recommended.

You can nest design grids indefinitely. To keep performance high, make sure to nest them directly in a ResponsiveDesignGridItem. If you get any errors, you might have to pass the parameter shouldCalculateLayout: true to the ResponsiveDesignGrid widget. This might happen most likely when the design grid does not get the full width of the app, or if you nested it inside another ResponsiveDesignGridItem and it doesn't get the full width there.

ResponsiveDesignGridRow widget will wrap its children, your rows should have as little children as possible. Avoid large Rows since this will impact performance.

Basic Usage
@override
Widget build(BuildContext context){
    return ResponsiveDesignGridConfig(
        child: ResponsiveDesignGrid(
            children: [
                ResponsiveDesignGridRow(
                    children: [
                        ResponsiveDesignGridItem(
                            columns: ResponsiveDesignGridColumns(
                                small: 12,
                                medium: 10,
                                large: 8,
                                extraLarge: 6,
                            ),
                            child: Placeholder(),
                        ),
                    ],
                )
            ],
        ),
    );
}
Adjusting Breakpoints

To change the default breakpoints values, you can use the breakpoints property in ResponsiveDesignGridConfig constructor which takes an instance of ResponsiveDesignGridBreakpoints class.

@override
Widget build(BuildContext context){
    return ResponsiveDesignGridConfig(
            breakpoints: const ResponsiveDesignGridBreakpoints(
            small: 375,
            medium: 768,
            large: 1280,
            extraLarge: 1920,
        ),
        child: ResponsiveDesignGrid(
            children: [
                ResponsiveDesignGridRow(
                    children: [
                        ResponsiveDesignGridItem(
                            columns: ResponsiveDesignGridColumns(
                                small: 12,
                                medium: 10,
                                large: 8,
                                extraLarge: 6,
                            ),
                            child: Placeholder(),
                        ),
                    ],
                )
            ],
        ),
    );
}
Customizing the grid

To change the amount of columns, the column spacing, the row spacing or the grid padding, you can use the theme property in ResponsiveDesignGridConfig constructor which takes an instance of ResponsiveDesignGridThemeData class.

@override
Widget build(BuildContext context){
    return ResponsiveDesignGridConfig(
        theme: ResponsiveDesignGridThemeData(
            columns: 12,
            columnSpacing: 16.0,
            rowSpacing: 16.0,
            gridPadding:16.0,
        ),
        child: ResponsiveDesignGrid(
            children: [
                ResponsiveDesignGridRow(
                    children: [
                        ResponsiveDesignGridItem(
                            columns: ResponsiveDesignGridColumns(
                                small: 12,
                                medium: 10,
                                large: 8,
                                extraLarge: 6,
                            ),
                            child: Placeholder(),
                        ),
                    ],
                )
            ],
        ),
    );
}
Material Design Grid

MaterialDesignGridTheme is required only once in your app, above the MaterialDesignGrid widget.

MaterialDesignGrid is not meant to be used nested due to material specifications.

MaterialDesignGridRow widget will wrap its children, you should size your rows as small as possible. Avoid large Rows since this will impact performance.

@override
Widget build(BuildContext context) {
    return MaterialDesignGridTheme(
        child: MaterialDesignGrid(
            children: [
                MaterialDesignGridRow(
                    children: [
                        MaterialDesignGridItem(
                            columns: 4,
                            child: Placeholder(),
                        ),
                    ],
                )
            ],
        ),
    );
}

📚 Additional information

All classes and exposed properties are well documented. If you find the documentation to be lacking, please create an issue 😊

Implementing a custom design grid approach

The base widgets used for both the ResponsiveDesignGrid as well as the MaterialDesignGrid can be found in lib/src/widgets. You can extend those to create your super-fancy very own custom design grid implementation 🥳.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。