showBottomList<T> static method

Future<T?> showBottomList<T>(
  1. List<String> list,
  2. dynamic onItemClick(
    1. int
    ), {
  3. double? radius,
  4. Color? bgColor,
  5. String cancelText = "取消",
  6. NullableIndexedWidgetBuilder? builder,
})

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);
}