搜尋套件、儲存庫與 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:[],
)

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。