一個 Flutter 套件,可無縫整合 Material Design ListTile 與可自訂的原生風格開關,支援 Material 和 Cupertino 風格。它提供一種簡潔優雅的解決方案,用於建立具有一致跨平台外觀的可切換清單項目。此組件設計旨在透過輕量級且易於使用的功能,提升使用者體驗,兼具功能性與美學吸引力。非常適合在設定或偏好設定畫面中頻繁使用開關的場景。
適用情境
設定介面
首選項面板
可切換的列表項目
使用者設定檔設定
表單控件
主要特色
可自訂的 Material 和 Cupertino 開關
無縫 ListTile 集成
跨平台一致性
輕量且高效
容易實現
樣式彈性
適合對象
開發設定螢幕的開發者
尋求原生樣式的切換開關的設計人員
需要跨平台切換元件的應用程式
強調介面潤飾的專案
使用建議
需要 Flutter 3.0+
僅限開關特定功能
除了標準轉換外,沒有內建動畫
複雜佈局可能需要額外的樣式
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
ListTileSwitch
ListTileSwitch is a simple widget that combines ListTile with a switch. Offering 3 types of switch widgets:
Switch: Material Switch from Material library on Flutter SDK.
CupertinoSwitch: CupertinoSwitch from Cupertino library on Flutter SDK.
A custom switch.
Tested on Android and Web but not iOS. Theoritacially it should work on iOS devices too, since this package contains nothing but pure Dart and Flutter components.
Installation
Add dependency for package on your pubspec.yaml:
dependencies:
list_tile_switch: <latest>
Usage
Use it as a regular ListTile widget with a bonus: the trailing widget is a switch. Covering all aspects of the ListTile and adding more with a custom switch.
Parameter
Definition
double switchScale
Adjusting the scale of the switch widget.
Color switchActiveColor
The color of the switch when the switch is active.
bool toggleSelectedOnValueChange
Deciding whether to color the ListTile when switch value is true, the selected color will be the switchActiveColor.