list static method

void list({
  1. required List<ExKeyValue> data,
  2. required String title,
  3. required String keySelected,
  4. required dynamic callback(
    1. String,
    2. String
    ),
  5. bool? isFullScreen,
  6. bool showDivider = true,
  7. Widget? onEmpty,
  8. double? radius = 16,
  9. bool showTrailing = false,
  10. TextStyle? titleStyle,
  11. Color? backgroundColor,
  12. Color? barrierColor,
  13. bool? isDismissible,
  14. bool? persistent,
  15. double? padding,
})

Implementation

static void list({
  required List<ExKeyValue> data,
  required String title,
  required String keySelected,
  required Function(String, String) callback,
  bool? isFullScreen,
  bool showDivider = true,
  Widget? onEmpty,
  double? radius = 16,
  bool showTrailing = false,
  TextStyle? titleStyle,
  Color? backgroundColor,
  Color? barrierColor,
  bool? isDismissible,
  bool? persistent,
  double? padding,
}) {
  // add haptic feedback (UX)
  HapticFeedback.lightImpact();
  Get.bottomSheet(
    SafeArea(
      child: VStack(
        [
          ExDashLine().pOnly(top: 24),
          title.text.bold
              .size(18)
              .maxLines(2)
              .ellipsis
              .make()
              .pOnly(top: 24, bottom: 8)
              .pSymmetric(h: 24),
          if (showDivider == true)
            Divider().pOnly(bottom: 8)
          else
            8.heightBox,
          Expanded(
            child: data.isNotEmpty
                ? ListView.separated(
                    separatorBuilder: (context, index) => Divider(),
                    itemCount: data.length,
                    itemBuilder: (context, index) {
                      return ListTile(
                        leading: data[index].icon,
                        title: data[index].key == keySelected
                            ? data[index].value.text.bold.size(14).make()
                            : data[index]
                                .value
                                .text
                                .color(Get.theme.hintColor)
                                .size(14)
                                .make(),
                        trailing: showTrailing == true
                            ? data[index].key == keySelected
                                ? Icon(Icons.radio_button_on)
                                : Icon(Icons.radio_button_off)
                            : null,
                        onTap: () {
                          Get.back();
                          callback(data[index].key, data[index].value);
                        },
                      );
                    },
                  )
                : onEmpty ?? 0.heightBox,
          ),
        ],
      ),
    ),
    backgroundColor: backgroundColor ?? Get.theme.cardColor,
    barrierColor: barrierColor,
    isDismissible: isDismissible ?? true,
    persistent: persistent ?? true,
    isScrollControlled: isFullScreen ?? false,
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
        topLeft: Radius.circular(radius ?? 16),
        topRight: Radius.circular(radius ?? 16),
      ),
    ),
  );
}