Choice 是一個現代的 Flutter 套件,專為建立彈性且可組合的選擇元件而設計,支援單一與多重選取。它取代了舊有的 smart_select 和 chips_choice 套件,提供更乾淨的 API 用於內嵌或提示式選擇介面。非常適合用於表單、篩選器與基於標籤的輸入,能在各平台提供一致且可自訂的體驗。此套件強調開發者的工作效率與介面彈性,讓整合到各種應用設計變得輕鬆。
適用情境
具有可選選項的表單輸入
過濾介面
基於標籤的資料輸入
動態選擇清單
使用者偏好選擇
多選下拉選單
主要特色
簡潔直覺的 API
支援單選與多選
靈活的內聯或提示佈局
高度可自訂的外觀
跨平台相容性
可組合的組件設計
適合對象
尋求現代替代方案以取代傳統選擇套件的開發者
需要動態、可重用選擇組件的應用程式
強調使用者介面一致性與可維護性的專案
優先考慮開發者體驗和程式碼清晰度的團隊
具有複雜篩選或標記需求的應用程式
使用建議
需要理解 Flutter 的 widget 組合
可能需要額外的樣式來支援複雜主題
與成熟的套件相比,文件較少
最適合頻繁使用者選擇的應用程式
不適合用於沒有互動性的簡單靜態選擇
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
The successor to smart_select and chips_choice with cleaner, more flexible, and composable API for creating inline or prompted choice widgets with single or multiple selection.
Features
Cleaner, flexible, and composable API
Inline or prompted choice widget
Single or multiple choice widget
Searchable choice items with highlighted result
Specifies whether the choice selection needs to be confirmed
Use any type of choice data and load it easily, either synchronously or asynchronously
Build your own choice item that fits your needs
Groupable choice items that can be sorted
Supports leading and trailing choice items, as well as divider choice items
Use a predefined wrapped, scrollable, virtualized choice list, or build one that fits your needs
Use a predefined popup dialog, bottom sheet, new page prompt, or build one that fits your needs
Use a predefined modal header, footer, and separator, or build one that fits your needs
Use a predefined group list, group item, and group header, or build one that fits your needs
Use a predefined anchor widget or build one that fits your needs
Use a predefined widget on loading, on error, and placeholder when empty, or build one that fits your needs
By default, the choice controller maintains the selection state within a List. Any constructors other than those dedicated to single choice will have a List<T> for their value and onChanged prop. If we want to use a single value of T, we can use ChoiceSingle.value adapter to fill the value prop and ChoiceSingle.onChanged adapter to fill the onChanged prop.
Here is an example of how to use the ChoiceSingle.value and ChoiceSingle.onChanged adapters
:x: Sortable choice items better to do this outside
:black_square_button: Add scroll wheel list
:black_square_button: Add dropdown choice widget
:black_square_button: Add chainable choice widget
Sponsoring
If this package or any other package I created is helping you, please consider to sponsor me so that I can take time to read the issues, fix bugs, merge pull requests and add features to these packages.