showSparkSingePicker<T> function

Future<T?> showSparkSingePicker<T>({
  1. required BuildContext context,
  2. required List<SparkPickerData<T>> options,
  3. double itemHeight = 40,
  4. SparkPickerBuilder? itemBuilder,
  5. bool showBar = true,
  6. String cancelText = '取消',
  7. String confirmText = '确定',
  8. TextStyle? cancelStyle,
  9. TextStyle? confirmStyle,
  10. double height = 300,
  11. SparkPickerTitleBarBuilder? barBuilder,
  12. T? defaultValue,
})

Implementation

Future<T?> showSparkSingePicker<T>({
  required BuildContext context,
  required List<SparkPickerData<T>> options,
  double itemHeight = 40,
  SparkPickerBuilder? itemBuilder,
  bool showBar = true,
  String cancelText = '取消',
  String confirmText = '确定',
  TextStyle? cancelStyle,
  TextStyle? confirmStyle,
  double height = 300,
  SparkPickerTitleBarBuilder? barBuilder,
  T? defaultValue,
}) {
  return showSparkModalSheet<T>(
    context: context,
    shape: _defaultPickerShape,
    builder: (BuildContext _ctx) {
      return _SparkMultiplePicker<T>(
        options: {_sparkPickerTag: options},
        itemHeight: itemHeight,
        itemBuilder: itemBuilder,
        showBar: showBar,
        cancelStyle: cancelStyle,
        cancelText: cancelText,
        confirmStyle: confirmStyle,
        confirmText: confirmText,
        height: height,
        barBuilder: barBuilder,
        defaultValue:
            defaultValue != null ? {_sparkPickerTag: defaultValue} : null,
        onConfirm: (_result) {
          Navigator.of(_ctx).pop(_result[_sparkPickerTag]);
        },
        onCancel: () {
          Navigator.of(_ctx).pop();
        },
      );
    },
  );
}