elevated static method
Widget
elevated({
- Key? key,
- VoidCallback? onPressed,
- VoidCallback? onLongPress,
- Size? minimumSize,
- EdgeInsetsGeometry? padding,
- double? horizontalPadding = 24,
- double? verticalPadding,
- EdgeInsetsGeometry? margin,
- double? horizontalMargin,
- double? verticalMargin,
- OutlinedBorder? shape,
- BorderSide? side,
- Color? primary,
- Color? onPrimary,
- Color? onSurface,
- double? elevation,
- TextStyle? textStyle,
- FocusNode? focusNode,
- bool back = false,
- bool? autofocus = false,
- bool round = false,
- bool enabled = true,
- bool busy = false,
- Clip? clipBehavior = Clip.none,
- Widget? child,
Create an elevated button.
Implementation
static Widget elevated({
Key? key,
VoidCallback? onPressed,
VoidCallback? onLongPress,
Size? minimumSize,
EdgeInsetsGeometry? padding,
double? horizontalPadding = 24,
double? verticalPadding,
EdgeInsetsGeometry? margin,
double? horizontalMargin,
double? verticalMargin,
OutlinedBorder? shape,
BorderSide? side,
Color? primary,
Color? onPrimary,
Color? onSurface,
double? elevation,
TextStyle? textStyle,
FocusNode? focusNode,
bool back = false,
bool? autofocus = false,
bool round = false,
bool enabled = true,
bool busy = false,
Clip? clipBehavior = Clip.none,
Widget? child,
}) =>
Builder(
builder: (context) => Container(
margin: margin ??
(horizontalMargin != null || verticalMargin != null
? EdgeInsets.symmetric(
horizontal: horizontalMargin ?? 0,
vertical: verticalMargin ?? 0,
)
: null),
child: ElevatedButton(
key: key,
onPressed: enabled
? busy
? () {}
: () {
onPressed?.call();
if (back) Get.back();
}
: null,
onLongPress: onLongPress,
style: ElevatedButton.styleFrom(
minimumSize: minimumSize,
padding: padding ??
(horizontalPadding != null || verticalPadding != null
? EdgeInsets.symmetric(
horizontal: horizontalPadding ?? 0,
vertical: verticalPadding ?? 0,
)
: null),
shape: shape ??
(round == true
? RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
)
: null),
side: side,
primary: primary,
onPrimary: onPrimary,
onSurface: onSurface,
elevation: elevation,
textStyle: textStyle,
),
focusNode: focusNode,
autofocus: autofocus ?? false,
clipBehavior: clipBehavior ?? Clip.none,
child: busy
? CircularProgress.small(
color: onPrimary ?? context.elevatedButtonForegroundColor,
)
: child,
),
),
);