getBottomSheetsHeader method

Widget getBottomSheetsHeader({
  1. required String title,
  2. required String warningText,
  3. int maxLines = 2,
  4. String? titleFontFamily,
  5. String? warningTextFontFamily,
  6. double? titleFontSize,
  7. double? warningTextFontSize,
  8. double warningTextLetterSpacing = 0.5,
  9. double warningTextHeight = 1.5,
  10. IconData? icon,
  11. Color iconColor = Colors.black,
  12. VoidCallback? onPressed,
  13. Color titleColor = Colors.black,
  14. Color warningTextColor = Colors.black,
})

Creates a header widget for bottom sheets with title, warning text, and close button.

Displays a customizable header for modal bottom sheets including a title, descriptive warning text, and a close icon button. Useful for alert-style bottom sheets.

Parameters:

  • title: The main heading text.
  • warningText: The descriptive or warning message below the title.
  • maxLines: Maximum lines for the title (defaults to 2).
  • titleFontFamily: Font family for title. Defaults to Utils.appFontFamily.textMainFontBoldFamily.
  • warningTextFontFamily: Font family for warning text. Defaults to Utils.appFontFamily.textMainFontRegular.
  • titleFontSize: Font size for title. Defaults to Utils.appFontFamily.textBottomSheetHeaderFontSize.
  • warningTextFontSize: Font size for warning text. Defaults to Utils.appFontFamily.textSmallFontSize.
  • warningTextLetterSpacing: Letter spacing for warning text (defaults to 0.5).
  • warningTextHeight: Line height for warning text (defaults to 1.5).
  • icon: Icon for the close button. Defaults to Icons.close.
  • iconColor: Color of the close icon (defaults to black).
  • onPressed: Callback when close button is pressed. Defaults to Get.back().
  • titleColor: Color for title text (defaults to black).
  • warningTextColor: Color for warning text (defaults to black).

Returns a Padding widget containing the bottom sheet header.

Layout structure:

  • Header row with title and close button
  • Vertical spacing
  • Warning text

Example:

getBottomSheetsHeader(
  title: 'Confirm Action',
  warningText: 'This action cannot be undone. Please confirm.',
  iconColor: Colors.red,
  onPressed: () => handleClose(),
);

Implementation

Widget getBottomSheetsHeader({
  required String title,
  required String warningText,
  int maxLines = 2,
  String? titleFontFamily,
  String? warningTextFontFamily,
  double? titleFontSize,
  double? warningTextFontSize,
  double warningTextLetterSpacing = 0.5,
  double warningTextHeight = 1.5,
  IconData? icon,
  Color iconColor = Colors.black,
  VoidCallback? onPressed,
  Color titleColor = Colors.black,
  Color warningTextColor = Colors.black,
}) {
  return Padding(
    padding: Utils.appConstants.headerPadding,
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        SizedBox(
          height: Utils.appConstants.headerHeight,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Align(
                alignment: Alignment.bottomLeft,
                child: Text(
                  title,
                  maxLines: maxLines,
                  textAlign: TextAlign.start,
                  style: TextStyle(
                      fontFamily: titleFontFamily ??
                          Utils.appFontFamily.textMainFontBoldFamily,
                      color: titleColor,
                      fontSize: titleFontSize ??
                          Utils.appFontFamily.textBottomSheetHeaderFontSize),
                ),
              ),
              Padding(
                padding: Utils.appConstants.btnClosePadding,
                child: IconButton(
                  icon: Icon(icon ?? Icons.close, color: iconColor),
                  //,color: Colors.orange,),
                  onPressed: () =>
                      onPressed ?? Get.back(), // null disables the button
                ),
              ),
            ],
          ),
        ),
        Utils.commonWidgets
            .addVerticalSpace(Utils.appConstants.zeroPointZeroTwo),
        Text(
          warningText,
          textAlign: TextAlign.start,
          style: TextStyle(
              fontFamily: warningTextFontFamily ??
                  Utils.appFontFamily.textMainFontRegular,
              color: warningTextColor,
              letterSpacing: warningTextLetterSpacing,
              height: warningTextHeight,
              fontSize: warningTextFontSize ??
                  Utils.appFontFamily.textSmallFontSize),
        )
      ],
    ),
  );
}