showPicker<T> static method
显示选择器
Implementation
static Future<T?> showPicker<T>({
required List<Widget> children,
ValueChanged<int>? onConfirm,
VoidCallback? onCancel,
Widget? cancel,
Widget? confirm,
bool useSafeArea = false,
double itemExtent = _defaultItemExtent,
int initialItem = 0,
Widget selectionOverlay = const CupertinoPickerDefaultSelectionOverlay(),
}) async {
final context = ComContext.context;
int selectIndex = initialItem;
return await showModalBottomSheet(
context: context,
useSafeArea: useSafeArea,
backgroundColor: Theme.of(context).dialogTheme.backgroundColor,
builder: (BuildContext context) => SizedBox(
height: _defaultDialogHeight,
child: Column(
children: [
_buildPickerHeader(
context: context,
cancel: cancel,
confirm: confirm,
onCancel: onCancel,
onConfirm: () {
if (onConfirm != null) {
onConfirm(selectIndex);
}
Navigator.of(context).pop();
},
),
SizedBox(
height: _defaultPickerHeight,
child: CupertinoPicker(
backgroundColor: Colors.transparent,
itemExtent: itemExtent,
onSelectedItemChanged: (int index) {
selectIndex = index;
},
selectionOverlay: selectionOverlay,
scrollController: FixedExtentScrollController(
initialItem: initialItem,
),
children: children,
),
),
],
),
),
);
}