showPicker static method
dynamic
showPicker({})
Implementation
static showPicker(
{required List<Widget> children,
Function(int selectIndex)? onConfirm,
Function()? onCancel,
Widget? cancel,
Widget? confirm,
bool useSafeArea = false,
double itemExtent = 30,
int initialItem = 0,
Widget selectionOverlay =
const CupertinoPickerDefaultSelectionOverlay()}) {
int selectIndex = initialItem;
showModalBottomSheet(
context: Get.context!,
useSafeArea: useSafeArea,
backgroundColor: Theme.of(Get.context!).dialogTheme.backgroundColor,
builder: (BuildContext context) => SizedBox(
height: 300,
child: Column(
children: [
Padding(
padding: EdgeInsets.only(
top: context.comTheme.spacing.medium,
left: context.comTheme.spacing.large,
right: context.comTheme.spacing.large),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: onCancel ?? () => Get.back(),
child: cancel ??
Text(
ComLocalizations.of(context).cancel,
style: Theme.of(context).textTheme.titleMedium,
),
),
GestureDetector(
onTap: () {
onConfirm?.call(selectIndex);
Get.back();
},
child: confirm ??
Text(
ComLocalizations.of(context).confirm,
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(
color: Theme.of(context).colorScheme.primary),
),
),
],
),
),
SizedBox(
height: 250,
child: CupertinoPicker(
backgroundColor: Colors.transparent,
itemExtent: itemExtent,
onSelectedItemChanged: (int index) {
selectIndex = index;
},
selectionOverlay: selectionOverlay,
scrollController:
FixedExtentScrollController(initialItem: initialItem),
children: children,
),
),
],
),
),
);
}