showBottomList<T> static method
Implementation
static Future<T?> showBottomList<T>(
List<String> list,
Function(int) onItemClick, {
double? radius, Color? bgColor, String cancelText = "取消",
NullableIndexedWidgetBuilder? builder,
}) async {
return await showBottom<T>(Column(mainAxisSize: MainAxisSize.min,
children: [
ConstrainedBox(constraints: BoxConstraints(maxHeight: Get.height*0.8),
child: ListView.separated(itemBuilder: (c,i){
return OnClick( builder!=null ? builder.call(c,i)! : Container(
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(vertical: 15),
child: Text(list[i],
style: TextStyle(color: Theme.of(Get.context!).textTheme.bodyMedium!.color, fontSize: 14),),),
onTap: () {
Navigator.of(Get.context!).pop();
onItemClick(i);
});
}, separatorBuilder: (c,i)=> const Divider(height: 1,),
padding: EdgeInsets.zero, shrinkWrap: true,
itemCount: list.length),),
Container(height: 8, color: Theme.of(Get.context!).dividerColor.withOpacity(0.2),),
OnClick(Container(padding: const EdgeInsets.symmetric(vertical: 15),
width: double.infinity, alignment: Alignment.center,
child: Text(cancelText, style: TextStyle(color: Theme.of(Get.context!).textTheme.bodyMedium!.color,
fontSize: 14),),), onTap: (){
Navigator.of(Get.context!).pop();
},)
],
), radius: radius, bgColor: bgColor);
}