Button.primary constructor
const
Button.primary({
- Key? key,
- WidgetStatesController? statesController,
- Widget? leading,
- Widget? trailing,
- required Widget child,
- VoidCallback? onPressed,
- FocusNode? focusNode,
- AlignmentGeometry? alignment,
- bool? enabled,
- AbstractButtonStyle style = ButtonVariance.primary,
- bool disableTransition = false,
- ValueChanged<
bool> ? onFocus, - ValueChanged<
bool> ? onHover, - bool disableHoverEffect = false,
- bool? enableFeedback,
- GestureTapDownCallback? onTapDown,
- GestureTapUpCallback? onTapUp,
- GestureTapCancelCallback? onTapCancel,
- GestureTapDownCallback? onSecondaryTapDown,
- GestureTapUpCallback? onSecondaryTapUp,
- GestureTapCancelCallback? onSecondaryTapCancel,
- GestureTapDownCallback? onTertiaryTapDown,
- GestureTapUpCallback? onTertiaryTapUp,
- GestureTapCancelCallback? onTertiaryTapCancel,
- GestureLongPressStartCallback? onLongPressStart,
- GestureLongPressUpCallback? onLongPressUp,
- GestureLongPressMoveUpdateCallback? onLongPressMoveUpdate,
- GestureLongPressEndCallback? onLongPressEnd,
- GestureLongPressUpCallback? onSecondaryLongPress,
- GestureLongPressUpCallback? onTertiaryLongPress,
- AlignmentGeometry? marginAlignment,
- bool disableFocusOutline = false,
Creates a primary button with prominent styling for main actions.
Primary buttons use a filled background with high contrast text, making them suitable for the most important action on a screen or in a section. They have the highest visual weight and should be used sparingly.
The button uses the primary color from the theme and provides clear visual feedback for hover, focus, and press states.
Parameters: Same as Button constructor, with style
preset to ButtonVariance.primary.
Example:
Button.primary(
onPressed: () => submitForm(),
child: Text('Submit'),
);
Implementation
const Button.primary({
super.key,
this.statesController,
this.leading,
this.trailing,
required this.child,
this.onPressed,
this.focusNode,
this.alignment,
this.enabled,
this.style = ButtonVariance.primary,
this.disableTransition = false,
this.onFocus,
this.onHover,
this.disableHoverEffect = false,
this.enableFeedback,
this.onTapDown,
this.onTapUp,
this.onTapCancel,
this.onSecondaryTapDown,
this.onSecondaryTapUp,
this.onSecondaryTapCancel,
this.onTertiaryTapDown,
this.onTertiaryTapUp,
this.onTertiaryTapCancel,
this.onLongPressStart,
this.onLongPressUp,
this.onLongPressMoveUpdate,
this.onLongPressEnd,
this.onSecondaryLongPress,
this.onTertiaryLongPress,
this.marginAlignment,
this.disableFocusOutline = false,
});