showCustomSheet<T, R> method

Future<SheetResponse<T>?> showCustomSheet<T, R>({
  1. dynamic variant,
  2. String? title,
  3. String? description,
  4. bool hasImage = false,
  5. String? imageUrl,
  6. bool showIconInMainButton = false,
  7. String? mainButtonTitle,
  8. bool showIconInSecondaryButton = false,
  9. String? secondaryButtonTitle,
  10. bool showIconInAdditionalButton = false,
  11. String? additionalButtonTitle,
  12. bool takesInput = false,
  13. Color barrierColor = Colors.black54,
  14. bool barrierDismissible = true,
  15. bool isScrollControlled = false,
  16. String barrierLabel = '',
  17. @Deprecated('Use `data` and pass in a generic type.') dynamic customData,
  18. R? data,
  19. bool enableDrag = true,
  20. Duration? exitBottomSheetDuration,
  21. Duration? enterBottomSheetDuration,
  22. bool? ignoreSafeArea,
  23. bool useRootNavigator = false,
})

Creates a popup with the given widget, a scale animation, and faded background.

The first generic type argument will be the BottomSheetResponse while the second generic type argument is the BottomSheetRequest

e.g.

await _bottomSheetService.showCustomSheet<GenericBottomSheetResponse, GenericBottomSheetRequest>();

Where GenericBottomSheetResponse is a defined model response, and GenericBottomSheetRequest is the request model.

Implementation

Future<SheetResponse<T>?> showCustomSheet<T, R>({
  dynamic variant,
  String? title,
  String? description,
  bool hasImage = false,
  String? imageUrl,
  bool showIconInMainButton = false,
  String? mainButtonTitle,
  bool showIconInSecondaryButton = false,
  String? secondaryButtonTitle,
  bool showIconInAdditionalButton = false,
  String? additionalButtonTitle,
  bool takesInput = false,
  Color barrierColor = Colors.black54,
  bool barrierDismissible = true,
  bool isScrollControlled = false,
  String barrierLabel = '',
  @Deprecated('Use `data` and pass in a generic type.') dynamic customData,
  R? data,
  bool enableDrag = true,
  Duration? exitBottomSheetDuration,
  Duration? enterBottomSheetDuration,
  bool? ignoreSafeArea,
  bool useRootNavigator = false,
}) {
  assert(
    _sheetBuilders != null,
    '''
    There's no sheet builder supplied for the variant:$variant. If you haven't yet setup your
    custom builder. Please call the setCustomSheetBuilders function on the service and supply
    the UI that you'd like to build for each variant.

    If you have already done that. Make sure that the variant:$variant has a builder associated
    with it.
    ''',
  );

  final sheetBuilder = _sheetBuilders![variant];

  return Get.bottomSheet<SheetResponse<T>>(
    Material(
      type: MaterialType.transparency,
      child: sheetBuilder!(
        Get.context!,
        SheetRequest<R>(
          title: title,
          description: description,
          hasImage: hasImage,
          imageUrl: imageUrl,
          showIconInMainButton: showIconInMainButton,
          mainButtonTitle: mainButtonTitle,
          showIconInSecondaryButton: showIconInSecondaryButton,
          secondaryButtonTitle: secondaryButtonTitle,
          showIconInAdditionalButton: showIconInAdditionalButton,
          additionalButtonTitle: additionalButtonTitle,
          takesInput: takesInput,
          // ignore: deprecated_member_use_from_same_package
          customData: customData,
          variant: variant,
          data: data,
        ),
        completeSheet,
      ),
    ),
    barrierColor: barrierColor,
    isDismissible: barrierDismissible,
    isScrollControlled: isScrollControlled,
    enableDrag: barrierDismissible && enableDrag,
    exitBottomSheetDuration: exitBottomSheetDuration,
    enterBottomSheetDuration: enterBottomSheetDuration,
    ignoreSafeArea: ignoreSafeArea,
    settings: RouteSettings(
        name: '$variant\_${_hashConcateator([
          title,
          description,
          mainButtonTitle,
          secondaryButtonTitle,
        ])}'),
    useRootNavigator: useRootNavigator,
  );
}