Flutter Button Widget

Banner image

GF Button is a Flutter Button that is a clickable element, that can be used for click events like click functions, page routing, social authentications, form submissions, or anywhere that needs simple, standard button functionality. Flutter Buttons have a broad area and can be used with any other widgets as well.

How to create GF Button in Flutter?

The Flutter Buttons are the very simple yet most commonly used component in almost all of the pages. The simple code of a GFButton looks like the following:

GFButton(
    onPressed: (){},
    text:"primary"
),

Flutter Disabled Button

The Flutter Disable Button is used to get a disabled button in the application. The disabled button will have a null value on the onPressed parameter. The simple code of the GFDisabled Button is as follows:

GFButton(                          
    onPressed: null,             
    text:"primary"
),

GF Flutter Button Properties

GF Buttons or Flutter Buttons are a very widely used component in any application. Hence the GFButtons are highly customizable and have a wide range of properties that gives a better look and feel for any application. The GFButton's properties are described below:

FLUTTER ELEVATED BUTTON

Flutter Elevated Button is a button in flutter which is the most commonly used flutter button which upon clicking, elevates or triggers to show the button action. The more customized properties can be seen in Gf Flutter Elevated Button

FLUTTER ROUNDED BUTTON

Flutter Rounded Button or Flutter Pills Button is a button in flutter wherein the corners of the buttons are circular in shape. In other words, it is a button with border-radius in it. For more customizable properties head to Flutter Pills/Rounded Button.

FLUTTER ICON BUTTON

Flutter Icon Button or Icon Button Flutter is a flutter button where the button has icons on them. It can even have a text which is a button with text or text with an icon which is a text icon button. To know more about Icon Button head to the Flutter Icon Button section

FLUTTER TOGGLE BUTTON

Flutter Toggle Button or Flutter Toggle Switch is a switch button that toggles between two states and the two states are often ON/OFF state.

For more information head to Flutter Toggle Switch Button

FLUTTER CIRCULAR BUTTON

Flutter circular button or Flutter Pills/Rounded Button is a type of Flutter Button that has circular corners in them. For more examples head to Flutter Circular button

FLUTTER BUTTON WIDGET MORE EXAMPLE CODE: You can follow our Blogs for more example demo code for the flutter button with GFButton.

How to Set Button Color in flutter?

Button Colors can be the background fill colors for solid buttons or the color can be for the border to the outline buttons.

GFColors are used to change the background of the button.

NameDescription
DescriptionThe color to use from the application color palette
Attributecolor
TypeGFColors
DefaultGFColors.PRIMARY

How to Set Button Size in Flutter?

Flutter Button can be of any size and can be changed according to the need.

GFSize can be used to determine the size of the buttons as follows:

NameDescription
DescriptionThe GFButton Size
Attributesize
TypeGFSize.LARGE, GFSize.MEDIUM, GFSize.SMALL
DefaultGFSize.MEDIUM

How to Change Button Shape in Flutter?

The shape of the button like standard, square, or pills can be determined by the shape property.

NameDescription
DescriptionThe GFButton Shape
Attributeshape
TypeGFButtonShape.standard, GFButtonShape.square, GFButtonShape.pills
DefaultGFButtonShape.standard

GF Flutter Button Type Properties

The button type of the button like solid, outline can be determined by the following properties:

NameDescription
DescriptionThe GFButton Type
Attributetype
TypeGFButtonType.solid, GFButtonType.outline, GFButtonType.outline2x, GFButtonType.transparent
DefaultGFButtonType.solid

How to change Button Position in Flutter?

The GFButton can be placed in the start or at the end of the position using the position property:

NameDescription
DescriptionPosition of icon in the button.
Attributeposition
TypeGFPosition.start, GFPosition.end
DefaultGFPosition.start

GFButton Custom Properties

Flutter Buttons can be customized using GFButton Custom properties which are listed below:

NameDescription
onPressedcallback i.e, called when the button is tapped
onLongPressedcallback i.e, called when the button is long-pressed
textdescribe the button's label. text will be a priority over child
icondescribe button's label with icon
childchild of type Widget alternative to text
textColorthe color to use for this button's text when the button is enabled
textStyledefines the styling of the text
disabledColorthe fillcolor of the button when the button is disabled
disabledTextColorthe color to use for this button's text when the button is disabled
borderSidedefines the border side
bordershapedefines the shape of the border
buttonBoxShadowif true, default boxShadow appears around the button.
boxShadowdefines the boxShadow
fullWidthButtonif true, defines the full width of the button.
blockButtonif true, defines the block button.
paddingdefines internal padding of the button
focusColorfillColor of the button when it has the input focused
hoverColorfillColor of the button when the pointer is hovered over it
splashColorindicates that the button has been touched
highlightColorindicates that the button is actively being pressed

quote

Last Updated: February 28, 2022