bottomSheetOptions static method

Future bottomSheetOptions(
  1. BuildContext context, {
  2. List<String>? option,
  3. String? defaultData,
  4. double maxHeight = 0.8,
  5. double minHeight = 0.1,
  6. dynamic onSelect(
    1. int index,
    2. String value
    )?,
  7. bool roundedFromTop = false,
  8. bool isDismissible = true,
  9. bool showItemDivider = false,
  10. bool enableDrag = true,
  11. Color? barrierColor,
  12. Color? backgroundColor,
  13. double? elevation,
  14. Clip? clipBehavior,
  15. bool isSafeAreaFromBottom = false,
})

Implementation

static Future bottomSheetOptions(BuildContext context,
    {List<String>? option,
    String? defaultData,
    double maxHeight = 0.8,
    double minHeight = 0.1,
    Function(int index, String value)? onSelect,
    bool roundedFromTop = false,
    bool isDismissible = true,
    bool showItemDivider = false,
    bool enableDrag = true,
    Color? barrierColor,
    Color? backgroundColor,
    double? elevation,
    Clip? clipBehavior,
    bool isSafeAreaFromBottom = false}) async {
  final result = await showModalBottomSheet(
    context: context,
    barrierColor: barrierColor,
    elevation: elevation,
    clipBehavior: clipBehavior,
    enableDrag: enableDrag,
    shape: roundedFromTop
        ? const RoundedRectangleBorder(
            borderRadius: BorderRadius.vertical(top: Radius.circular(25.0)))
        : null,
    isScrollControlled: true,
    isDismissible: isDismissible,
    backgroundColor:
        backgroundColor ?? Theme.of(context).colorScheme.background,
    builder: (BuildContext context) {
      return SafeArea(
        bottom: isSafeAreaFromBottom,
        child: AnimatedPadding(
          padding: MediaQuery.viewInsetsOf(context),
          duration: const Duration(milliseconds: 100),
          child: _VxBottomSheetOptions(
            list: option,
            initData: defaultData,
            maxHeight: maxHeight,
            minHeight: minHeight,
            showItemDivider: showItemDivider,
          ),
        ),
      );
    },
  );

  if (onSelect != null && result is List) {
    onSelect(result.first, result.last);
  }
  return result;
}