FxButton class
A customizable button widget that follows a specific design style.
The FxButton widget provides various customization options such as text, icons, colors, shapes, sizes, and more. It supports different button types like solid, outline, outline2x, and transparent. The appearance and behavior of the button can be modified using the provided properties.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FxButton
- Available extensions
Constructors
-
FxButton.new({required VoidCallback onPressed, Key? key, String? text, IconData? icon, Color? color, Color? outlineColor, BtnShape shape = BtnShape.rounded, BtnSize size = BtnSize.normal, BtnType type = BtnType.solid, bool isBlock = false, IconData? prefixIcon, IconData? suffixIcon, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, BorderRadius? radius, List<
BoxShadow> ? shadow, Color? textColor, Color? iconColor, bool isSplashColor = false, MainAxisAlignment? mainAxisAlignment, double? iconSize, TextStyle? textStyle, Widget? child, bool isLoading = false, Widget? loadingWidget, double? loadingSize, Color? loadingColor}) -
constructor
const
Properties
- bottomCenter → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the bottom-center of its parent.no setter - bottomLeft → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the bottom-left corner of its parent.no setter - bottomRight → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the bottom-right corner of its parent.no setter - center → Center
-
Available on Widget, provided by the WidgetExtension extension
Centers the current widget.no setter - centerLeft → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the center-left of its parent.no setter - centerRight → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the center-right of its parent.no setter - child → Widget?
-
A custom child widget to use instead of text and icons.
final
- color → Color?
-
The color parameter sets the button's background color for the solid
button type.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → IconData?
-
The icon parameter specifies the icon to be displayed in the center without text.
final
- iconColor → Color?
-
The iconColor parameter sets the color for the prefix and suffix
icons. If not provided, the icon color will be determined based on the
button's background color.
final
- iconSize → double?
-
The iconSize parameter determines the icons's size.
final
- isBlock → bool
-
The isBlock parameter indicates whether the button should occupy the
full width available.
final
- isLoading → bool
-
Indicates whether the button is in a loading state.
When true, the button will display a loading indicator instead of its content.
final
- isSplashColor → bool
-
A boolean value indicating whether splash color is enabled for the button.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingColor → Color?
-
Color of the default loading indicator if no custom loadingWidget is provided.
final
- loadingSize → double?
-
Size of the default loading indicator if no custom loadingWidget is provided.
final
- loadingWidget → Widget?
-
Custom widget to display when the button is in a loading state.
If not provided, a CircularProgressIndicator will be used.
final
- mainAxisAlignment → MainAxisAlignment?
-
Defines how the children should be placed along the main axis.
final
- margin → EdgeInsetsGeometry?
-
The margin parameters allow customization of the button's external padding.
final
- onPressed → VoidCallback
-
The onPressed parameter is required and defines the callback function
when the button is pressed.
final
- opacity0 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 0% opacity, making it fully invisible.no setter - opacity10 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 10% opacity.no setter - opacity100 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 100% opacity, making it fully visible.no setter - opacity20 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 20% opacity.no setter - opacity25 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 25% opacity.no setter - opacity50 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 50% opacity, making it half visible.no setter - opacity75 → Opacity
-
Available on Widget, provided by the OpacityExtension extension
Returns the widget with 75% opacity.no setter - outlineColor → Color?
-
The outlineColor parameter sets the button's outline color for the
outline button types.
final
- p0 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 0dp padding to all sides.no setter - p1 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 1dp padding to all sides.no setter - p10 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 10dp padding to all sides.no setter - p11 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 11dp padding to all sides.no setter - p12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding to all sides.no setter - p16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding to all sides.no setter - p2 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 2dp padding to all sides.no setter - p20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding to all sides.no setter - p24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding to all sides.no setter - p3 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 3dp padding to all sides.no setter - p32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding to all sides.no setter - p4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding to all sides.no setter - p48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding to all sides.no setter - p5 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 5dp padding to all sides.no setter - p6 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 6dp padding to all sides.no setter - p64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding to all sides.no setter - p7 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 7dp padding to all sides.no setter - p8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding to all sides.no setter - p9 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 9dp padding to all sides.no setter - padding → EdgeInsetsGeometry?
-
The padding parameters allow customization of the button's internal padding
final
- pb0 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 0dp padding to the bottom side.no setter - pb12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding to the bottom side.no setter - pb16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding to the bottom side.no setter - pb20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding to the bottom side.no setter - pb24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding to the bottom side.no setter - pb32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding to the bottom side.no setter - pb4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding to the bottom side.no setter - pb48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding to the bottom side.no setter - pb64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding to the bottom side.no setter - pb8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding to the bottom side.no setter - pl0 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 0dp padding to the left side.no setter - pl12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding to the left side.no setter - pl16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding to the left side.no setter - pl20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding to the left side.no setter - pl24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding to the left side.no setter - pl32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding to the left side.no setter - pl4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding to the left side.no setter - pl48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding to the left side.no setter - pl64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding to the left side.no setter - pl8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding to the left side.no setter - pr0 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 0dp padding to the right side.no setter - pr12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding to the right side.no setter - pr16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding to the right side.no setter - pr20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding to the right side.no setter - pr24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding to the right side.no setter - pr32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding to the right side.no setter - pr4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding to the right side.no setter - pr48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding to the right side.no setter - pr64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding to the right side.no setter - pr8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding to the right side.no setter - prefixIcon → IconData?
-
The prefixIcon parameter specifies the icon to be displayed before the button text.
final
- pt0 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 0dp padding to the top side.no setter - pt12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding to the top side.no setter - pt16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding to the top side.no setter - pt20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding to the top side.no setter - pt24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding to the top side.no setter - pt32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding to the top side.no setter - pt4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding to the top side.no setter - pt48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding to the top side.no setter - pt64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding to the top side.no setter - pt8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding to the top side.no setter - px12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding horizontally.no setter - px16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding horizontally.no setter - px20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding horizontally.no setter - px24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding horizontally.no setter - px32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding horizontally.no setter - px4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding horizontally.no setter - px48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding horizontally.no setter - px64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding horizontally.no setter - px8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding horizontally.no setter - py12 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 12dp padding vertically.no setter - py16 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 16dp padding vertically.no setter - py20 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 20dp padding vertically.no setter - py24 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 24dp padding vertically.no setter - py32 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 32dp padding vertically.no setter - py4 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 4dp padding vertically.no setter - py48 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 48dp padding vertically.no setter - py64 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 64dp padding vertically.no setter - py8 → Padding
-
Available on Widget, provided by the PaddingExtension extension
Applies 8dp padding vertically.no setter - radius → BorderRadius?
-
The radius parameter determines the button's border radius. If not
provided, the default border radius will be based on the button's shape.
final
- rounded → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 15 logical pixels to the widget.no setter - roundedFull → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a circular border radius to the widget, making it a full circle.no setter - roundedLg → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 25 logical pixels to the widget.no setter - roundedMd → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 20 logical pixels to the widget.no setter - roundedNone → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Removes the border radius from the widget, making it square.no setter - roundedSm → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 10 logical pixels to the widget, making it more rounded.no setter - roundedXl → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 30 logical pixels to the widget.no setter - roundedXs → ClipRRect
-
Available on Widget, provided by the RadiusExtension extension
Applies a border radius of 5 logical pixels to the widget, making it slightly rounded.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shadow
→ List<
BoxShadow> ? -
The shadow parameter allows specifying a list of box shadows to create
a shadow effect for the button.
final
- shape → BtnShape
-
The shape parameter specifies the button's shape, which can be one of
the values in the BtnShape enum.
final
- size → BtnSize
-
The size parameter determines the button's size, which can be one of
the values in the BtnSize enum.
final
- suffixIcon → IconData?
-
The suffixIcon parameter specifies the icon to be displayed after the button text.
final
- text → String?
-
The text parameter specifies the button's label text.
final
- textColor → Color?
-
The textColor parameter sets the text color for the solid button type.
If not provided, the text color will be automatically determined based on
the button's background color.
final
- textStyle → TextStyle?
-
The style to use for the button's text.
final
- topCenter → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the top-center of its parent.no setter - topLeft → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the top-left corner of its parent.no setter - topRight → Align
-
Available on Widget, provided by the AlignExtension extension
Aligns the child widget to the top-right corner of its parent.no setter - type → BtnType
-
The type parameter defines the button's type, which can be one of the
values in the BtnType enum.
final
Methods
-
align(
[Alignment alignment = Alignment.center]) → Align -
Available on Widget, provided by the AlignExtension extension
Aligns the child widget within its parent. -
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
expand(
[int flex = 1]) → Expanded -
Available on Widget, provided by the WidgetExtension extension
Expands the current widget to fill available space. -
flexible(
[int flex = 1, FlexFit fit = FlexFit.loose]) → Flexible -
Available on Widget, provided by the WidgetExtension extension
Makes the current widget flexible. -
getBtnPadding(
) → EdgeInsets -
getBtnShape(
) → BorderRadius - Returns the border radius for the button based on its shape.
-
getBtnSize(
) → double - Returns the size factor for the button based on its size.
-
getBtnType(
BuildContext context) → Color - Returns the button color based on its type. If the type is BtnType.outline, BtnType.outline2x, or BtnType.transparent, returns Colors.transparent. Otherwise, returns FxColor.primary.
-
getButtonBorder(
) → Border - Returns the appropriate border for the button based on its type.
-
getTextColor(
Color color) → Color - Returns the text color for the button based on the background color. If the background color is transparent, returns FxColor.gray700. Otherwise, returns FxColor.gray700 for light background colors and Colors.white for dark background colors.
-
hBox(
double height) → SizedBox -
Available on Widget, provided by the WidgetExtension extension
Creates a SizedBox with specified height and the current widget as its child. -
hide(
bool isVisible, {bool maintainSize = false}) → Visibility -
Available on Widget, provided by the WidgetExtension extension
Hides the current widget based on a condition. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDoubleTap(
VoidCallback callback) → GestureDetector -
Available on Widget, provided by the GestureExtension extension
Wraps the currentWidget
in aGestureDetector
widget with a double tap gesture callback. -
onInkDoubleTap(
VoidCallback callback, {Color? splashColor, Color? focusColor, Color? hoverColor, bool enableFeedback = false, double? radius, BorderRadius? borderRadius, MouseCursor? mouseCursor}) → InkWell -
Available on Widget, provided by the GestureExtension extension
Wraps the currentWidget
in anInkWell
widget with a double tap gesture callback and customizable ink splash parameters. -
onInkTap(
VoidCallback callback, {Color? splashColor, Color? focusColor, Color? hoverColor, bool enableFeedback = false, double? radius, BorderRadius? borderRadius, MouseCursor? mouseCursor}) → InkWell -
Available on Widget, provided by the GestureExtension extension
Wraps the currentWidget
in anInkWell
widget with a tap gesture callback and customizable ink splash parameters. -
onLongPress(
VoidCallback callback) → GestureDetector -
Available on Widget, provided by the GestureExtension extension
Wraps the currentWidget
in aGestureDetector
widget with a long press gesture callback. -
onTap(
VoidCallback callback) → GestureDetector -
Available on Widget, provided by the GestureExtension extension
Wraps the currentWidget
in aGestureDetector
widget with a tap gesture callback. -
opacity(
double opacity) → Opacity -
Available on Widget, provided by the OpacityExtension extension
Wraps the widget in an Opacity widget with the given opacity. -
p(
double all) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies equal padding to all sides. -
pb(
double bottom) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to the bottom side. -
pl(
double left) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to the left side. -
pnb(
double value) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to all sides except bottom. -
pnl(
double value) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to all sides except left. -
pnr(
double value) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to all sides except right. -
pnt(
double value) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to all sides except top. -
pOnly(
{double top = 0, double bottom = 0, double left = 0, double right = 0}) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding only to the specified sides. -
positioned(
{double? top, double? bottom, double? left, double? right, double? height, double? width}) → Positioned -
Available on Widget, provided by the WidgetExtension extension
Positions the current widget within a Stack. -
pr(
double right) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to the right side. -
pt(
double top) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies padding to the top side. -
px(
double h) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies horizontal padding. -
pxy(
{required double h, required double v}) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies symmetric padding with different horizontal and vertical values. -
py(
double v) → Padding -
Available on Widget, provided by the PaddingExtension extension
Applies vertical padding. -
shimmer(
{double height = 200.0, double width = double.infinity, Color highlightColor = FxColor.gray300, Color baseColor = FxColor.gray400, Duration duration = const Duration(milliseconds: 1000), Duration interval = const Duration(milliseconds: 500), Gradient? gradient, Axis direction = Axis.horizontal}) → Widget -
Available on Widget, provided by the ShimmerExtension extension
Apply shimmer effect to the widget. -
show(
bool isVisible, {bool maintainSize = false}) → Visibility -
Available on Widget, provided by the WidgetExtension extension
Shows the current widget based on a condition. -
sizedBox(
{double? h, double? w}) → SizedBox -
Available on Widget, provided by the WidgetExtension extension
Wraps the current widget in a SizedBox with specified dimensions. -
sqBox(
double size) → SizedBox -
Available on Widget, provided by the WidgetExtension extension
Creates a square SizedBox with the current widget as its child. -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
wBox(
double? width) → SizedBox -
Available on Widget, provided by the WidgetExtension extension
Creates a SizedBox with specified width and the current widget as its child. -
withRounded(
{required double radius}) → ClipRRect -
Available on Widget, provided by the RadiusExtension extension
Adds rounded corners to the widget with a specified radius.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited