Flutter 實(shí)現(xiàn)單選或者多選

一次學(xué)習(xí)Flutter的過程,一個簡單的單選或者多選。

地址

github
pub

截圖

1.gif

導(dǎo)入

flutter_sujian_select:^1.0.1
import 'package:flutter_sujian_select/flutter_select.dart';

使用

單選

SelectGroup<int>(
              index:0,
              items: <SelectItem<int>>[
                SelectItem(label: '30天',value: 1),
                SelectItem(label: '60天',value: 2),
                SelectItem(label: '90天',value: 3),
              ],
              onSingleSelect: (int value){
              
              },
            ),

多選

SelectGroup<int>(
              type: SelectType.multiple,
              style: SelectStyle.rectangle,
              direction: SelectDirection.vertical,
              listIndex: [1,2],
              items: <SelectItem<int>>[
                SelectItem(label: '1',value: 1),
                SelectItem(label: '2',value: 2),
                SelectItem(label: '3',value: 3),
                SelectItem(label: '4',value: 4),
              ],
              onMultipleSelect: (List<int> value){
             
              },
            ),

屬性說明

屬性 描述 默認(rèn)值
borderColor 邊框顏色 Colors.blue
unSelectColor 未選中背景顏色 Colors.white
selectColor 選中顏色 Colors.blue
space item之間的距離 const EdgeInsets.all(0.0)
padding 內(nèi)邊距 const EdgeInsets.all(8.0)
isRepeatBorderLine 是否去掉重復(fù)的線(矩形生效) false
type 選擇類型 SelectType.single
style item風(fēng)格 SelectStyle.circular
direction 排列方向 SelectDirection.horizontal
index 默認(rèn)值(單選可用) null
listIndex 默認(rèn)值(多選可用) null
onSingleSelect 單選回調(diào)(單選可用) null
onMultipleSelect 多選回調(diào)(單選可用) null
items 選項(xiàng)(必要) null
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容