SwitchUp 是一個高度可自定義的動畫切換開關,適用於 Flutter 應用程式。它允許開發者透過調整寬度、顏色、文字標籤、圓角半徑和流暢的動畫效果來客製化開關外觀。該組件會自動維護其選取狀態,確保無縫的使用者互動。設計簡潔且彈性,可輕鬆整合至表單、設定面板或任何需要切換功能的 UI 中。其乾淨的 API 支援明暗模式適應,非常適合現代應用設計。
適用情境
使用者偏好切換
設定開關
表單輸入控制項
啟用/停用深色模式
開/關狀態指示燈
主要特色
完全可自定義的外觀
平滑的動畫過渡
狀態持久化
可調整的寬度與角落半徑
支援自訂文字標籤
支援淺色與深色模式
適合對象
簡單的切換介面
可自定義的 UI 組件
設定螢幕
行動應用程式開發
Flutter 初學者與專家
使用建議
未提及特定平台的整合
僅限視覺自訂
未注意到內建的无障碍功能
需要手動處理焦點和語義
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
README
Switch Up
An animated toggle switch which can be fully customized with desired width, colors, text, corner radius, animation etc. It also maintains selection state.
Getting Started
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies: ... switch_up:latest_version
Import it:
import'package:switch_up/switch_up.dart';
Usage Examples
// Here, default theme color are used for selected item.SwitchUp<String>(
backgroundColor: Colors.grey.shade200,
items: const <String>['Home', 'Chat', 'Settings'],
onChanged: (String value) {
print(value);
},
value: 'Settings',
),