showSnackBar method

void showSnackBar({
  1. String? message,
  2. Icon? icon,
  3. Color? color,
  4. Color? textColor,
  5. double height = 60,
  6. SnackBar? snackBar,
  7. Color? borderColor,
  8. bool? showCloseIcon,
  9. int duration = 2000,
  10. double elevation = 0,
  11. Color? closeIconColor,
  12. EdgeInsetsGeometry? margin,
  13. EdgeInsetsGeometry? padding,
  14. SnackBarBehavior behavior = SnackBarBehavior.fixed,
})

Displays a bottom sheet with the specified child widget.

The optional title parameter sets the title of the bottom sheet. The height parameter can be used to set the height of the bottom sheet. The modal parameter determines whether the bottom sheet is modal or not. The titleTextStyle parameter sets the text style for the title. Shows a snackbar with the specified properties.

The icon parameter sets the icon for the snackbar. The color parameter sets the background color of the snackbar. The textColor parameter sets the text color of the snackbar. The borderColor parameter sets the border color of the snackbar. The snackBar parameter defines the SnackBar if the message is null and the other parameters are ignored. The showCloseIcon parameter determines whether to show a close icon on the snackbar. The duration parameter sets the duration for which the snackbar is displayed. The elevation parameter sets the elevation of the snackbar. The closeIconColor parameter sets the color of the close icon. The message parameter specifies the text message to be displayed in the snackbar.

Implementation

// FutureOr<dynamic> showBottomSheet<T>() {}

/// Shows a snackbar with the specified properties.
///
/// The [icon] parameter sets the icon for the snackbar.
/// The [color] parameter sets the background color of the snackbar.
/// The [textColor] parameter sets the text color of the snackbar.
/// The [borderColor] parameter sets the border color of the snackbar.
/// The [snackBar] parameter defines the SnackBar if the message is null
/// and the other parameters are ignored.
/// The [showCloseIcon] parameter determines whether to show a close
/// icon on the snackbar.
/// The [duration] parameter sets the duration for which the snackbar
/// is displayed.
/// The [elevation] parameter sets the elevation of the snackbar.
/// The [closeIconColor] parameter sets the color of the close icon.
/// The [message] parameter specifies the text message to be displayed
/// in the snackbar.
void showSnackBar({
  String? message,
  Icon? icon,
  Color? color,
  Color? textColor,
  double height = 60,
  SnackBar? snackBar,
  Color? borderColor,
  bool? showCloseIcon,
  int duration = 2000,
  double elevation = 0,
  Color? closeIconColor,
  EdgeInsetsGeometry? margin,
  EdgeInsetsGeometry? padding,
  SnackBarBehavior behavior = SnackBarBehavior.fixed,
}) {
  assert(
    snackBar != null || message != null,
    'Add a snackbar or use the default snackbar which requires a message.',
  );
  ScaffoldMessenger.of(this)
    ..hideCurrentSnackBar()
    ..showSnackBar(
      snackBar ??
          SnackBar(
            content: SuperSnackbar(
              icon: icon,
              color: color,
              height: height,
              message: message!,
              duration: duration,
              textColor: textColor,
              borderColor: borderColor,
            ),
            margin: margin,
            behavior: behavior,
            elevation: elevation,
            showCloseIcon: showCloseIcon,
            closeIconColor: closeIconColor,
            backgroundColor: Colors.transparent,
            padding: behavior == SnackBarBehavior.floating
                ? padding ?? const EdgeInsets.symmetric(horizontal: 5)
                : padding,
          ),
    );
}