Added constraint parameter

This commit is contained in:
2026-04-19 15:56:11 +02:00
parent 2ad3698067
commit ad2e4bc398
2 changed files with 9 additions and 8 deletions

View File

@@ -7,22 +7,23 @@ class AnimatedDialogButton extends StatefulWidget {
/// - [onPressed]: Callback function that is triggered when the button is pressed. /// - [onPressed]: Callback function that is triggered when the button is pressed.
/// - [buttonText]: The text to be displayed on the button. /// - [buttonText]: The text to be displayed on the button.
/// - [buttonType]: The type of the button, which determines its styling. /// - [buttonType]: The type of the button, which determines its styling.
/// - [buttonConstraints]: Optional constraints to control the button's size.
const AnimatedDialogButton({ const AnimatedDialogButton({
super.key, super.key,
required this.onPressed,
required this.buttonText, required this.buttonText,
this.constraints, required this.onPressed,
this.buttonConstraints,
this.buttonType = ButtonType.primary, this.buttonType = ButtonType.primary,
}); });
final BoxConstraints? constraints;
final ButtonType buttonType;
final String buttonText; final String buttonText;
final VoidCallback onPressed; final VoidCallback onPressed;
final BoxConstraints? buttonConstraints;
final ButtonType buttonType;
@override @override
State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState(); State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState();
} }
@@ -68,7 +69,7 @@ class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
child: Center( child: Center(
child: Container( child: Container(
constraints: widget.constraints, constraints: widget.buttonConstraints,
decoration: buttonDecoration, decoration: buttonDecoration,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
margin: const EdgeInsets.symmetric(vertical: 8), margin: const EdgeInsets.symmetric(vertical: 8),

View File

@@ -26,7 +26,7 @@ class CustomDialogAction extends StatelessWidget {
onPressed: onPressed, onPressed: onPressed,
buttonText: text, buttonText: text,
buttonType: buttonType, buttonType: buttonType,
constraints: const BoxConstraints(minWidth: 300), buttonConstraints: const BoxConstraints(minWidth: 300),
); );
} }
} }