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

simple_grid 封面
插件详情v0.1.5

simple_grid

一个受 Bootstrap 启发的动态网格,您可以使用它来描述您的网格布局。此包完全使用 MediaQuery,无需担心渲染。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
955
喜欢数
79
Pub 分数
160

安装插件

flutter pub add simple_grid

插件介绍

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

Simple Grid 是一个适用于 Flutter 的响应式网格布局包,其灵感来自 Bootstrap。它利用 MediaQuery,使开发者能够定义灵活、动态的网格系统,确保布局在不同屏幕尺寸和平台间无缝适应。该包通过抽象复杂的计算,简化了响应式 UI 设计,使开发者无需关注手动渲染即可直观地定义网格。非常适合用于构建跨移动、网页和桌面应用的一致且可扩展的界面。

适合场景

  • 构建响应式仪表板
  • 创建自适应卡片布局
  • 设计多列表单
  • 开发跨平台 UI
  • 实现流体内容网格

主要特点

  • 基于 MediaQuery 的响应式设计
  • 受 Bootstrap 启发的语法
  • 无需手动渲染
  • 跨平台支持
  • 简单的声明式网格定义

适合对象

  • 初学者Flutter开发者
  • 响应式UI设计师
  • 跨平台应用程序创建者
  • 快速原型团队
  • 布局重点的项目

使用建议

  • 超出网格结构的自定义功能有限
  • 依赖 MediaQuery 的准确性
  • 不适合高度复杂的布局
  • 可能需要额外的样式才能实现高级设计
  • 最适合标准网格图案

原始 README

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

Indonesian documentation is here

Introduction

pub package build

Inspired by bootstrap , This is dynamic grid layout that you can use Like a bootstrap grid, but the size following material UI break points. You can also customize your break point like here. This package purely using mediaquery, don't worry about the render.

Simple Demo

code example here

Order Demo

code example here

Grid Explanation

Bootstrap, material-ui or another web-grid always use 12 size. Here is the image example:

Classes

There are 4 classes that you have to now, these are:

  1. SpGrid is the container of grid, more information here
  2. SpGridItem is the children of SpGrid, more information here
  3. SpGridSize is the class that you can declare the maximum of the screen size, more information here
  4. SpOrder, this class is a sort class. when you use 1 of it's value, the value will create an ordering when the screen on the value condition. more information here

Example

SpGrid(width: MediaQuery.of(context).size.width, children: [
  SpGridItem(
    xs: 12,
    sm: 6,
    md: 4,
    lg: 3,
    child: Container(
      color: Colors.blue,
      height: 200,
    ),
  ),
  SpGridItem(
    xs: 12,
    sm: 6,
    md: 4,
    lg: 3,
    child: Container(
      color: Colors.green,
      height: 200,
    ),
  ),
  SpGridItem(
    xs: 12,
    sm: 6,
    md: 4,
    lg: 3,
    child: Container(
      color: Colors.yellow,
      height: 200,
    ),
  ),
  SpGridItem(
    xs: 12,
    sm: 6,
    md: 4,
    lg: 3,
    child: Container(
      color: Colors.purple,
      height: 200,
    ),
  ),
]);

Order Example

import 'package:flutter/material.dart';
import 'package:simple_grid/simple_grid.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Simple_grid',
      theme: ThemeData(
        brightness: Brightness.dark,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("SIMPLE GRID EXAMPLE"),
      ),
      body: SpGrid(
        width: MediaQuery.of(context).size.width,
        spacing: 10,
        runSpacing: 10,
        children: [
          SpGridItem(
            xs: 12,
            md: 6,
            order: SpOrder(sm: 1, xs: 1),
            child: Container(
              height: 200,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    "Hello!",
                    style: TextStyle(fontSize: 40),
                    textAlign: TextAlign.center,
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  Text(
                    "I'm John Doe and I Love Programming",
                    style: TextStyle(fontSize: 25),
                    textAlign: TextAlign.center,
                  ),
                ],
              ),
            ),
          ),
          SpGridItem(
            xs: 12,
            md: 6,
            order: SpOrder(sm: 0, xs: 0),
            child: Container(
              height: 200,
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: NetworkImage(
                          "https://raw.githubusercontent.com/nggepe/simple_grid/master/doc/john.png"))),
            ),
          ),
        ],
      ),
    );
  }
}

Customize Break Point

SpGrid(
  width: MediaQuery.of(context).size.width,
  gridSize: SpGridSize(xs: 0, sm: 500, md: 768, lg: 980, xl: 1200),
  children:[],
)

所属分类

源码仓库

使用此插件的项目

暂无相关数据。