搜尋套件、儲存庫與 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

原始碼儲存庫

使用此套件的專案

暫無相關資料。