list static method
void
list({
- required List<
ExKeyValue> data, - required String title,
- required String keySelected,
- required dynamic 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,
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),
),
),
);
}