showMaterialResponsiveDialog<T> function

Future<T?> showMaterialResponsiveDialog<T>(
  1. {required BuildContext context,
  2. String? title,
  3. Widget? child,
  4. bool hideButtons = false,
  5. Color? headerColor,
  6. Color? headerTextColor,
  7. Color? backgroundColor,
  8. Color? buttonTextColor,
  9. String? confirmText,
  10. bool cancelButtonVisible = true,
  11. String? cancelText,
  12. double? maxLongSide,
  13. double? maxShortSide,
  14. VoidCallback? onConfirmed,
  15. VoidCallback? onCancelled}

Extends Dialog by making it responsive to screen orientation changes


Future<T?> showMaterialResponsiveDialog<T>({
  required BuildContext context,

  /// The title for the dialog box
  String? title,

  /// The content to place inside the dialog
  Widget? child,

  /// Don't include the buttons
  bool hideButtons = false,

  /// The dialog header color (overrides theme)
  Color? headerColor,

  /// The dialog header text color (overrides theme)
  Color? headerTextColor,

  /// The dialog background color (overrides theme)
  Color? backgroundColor,

  /// The button text color (overrides theme)
  Color? buttonTextColor,

  /// Text to display in the confirm button
  String? confirmText,

  /// Whether to display a cancel button
  bool cancelButtonVisible = true,

  /// Text to display in the cancel button
  String? cancelText,

  /// Used to restrict how tall the dialog can be.
  double? maxLongSide,

  /// Used to restrict how wide the dialog can be.
  double? maxShortSide,

  /// Function that gets called when the confirm button is pressed
  VoidCallback? onConfirmed,

  /// Function that gets called when the cancel button is pressed
  VoidCallback? onCancelled,
}) {
  return showDialog<T>(
    context: context,
    barrierDismissible: hideButtons,
    builder: (BuildContext context) {
      return ResponsiveDialog(
        context: context,
        title: title,
        headerColor: headerColor,
        headerTextColor: headerTextColor,
        backgroundColor: backgroundColor,
        buttonTextColor: buttonTextColor,
        confirmText: confirmText,
        cancelButtonVisible: cancelButtonVisible,
        cancelText: cancelText,
        maxLongSide: maxLongSide,
        maxShortSide: maxShortSide,
        hideButtons: hideButtons,
        child: child,
        okPressed: () {
          if (onConfirmed != null) onConfirmed();
        cancelPressed: () {
          if (onCancelled != null) onCancelled();