Flutter Buttons
D. Gichuki,
Buttons
• Buttons are the graphical control element that
provides a user to trigger an event such as
taking actions, making choices, searching things,
and many more.
• They can be placed anywhere in our UI like
dialogs, forms, cards, toolbars, etc.
• Buttons are the Flutter widgets, which is a part
of the material design library.
• Flutter provides several types of buttons that
have different shapes, styles, and features.
Buttons
• The standard features of a button in Flutter are
given below:
– We can easily apply themes on buttons,
shapes, color, animation, and behavior.
– We can also theme icons and text inside the
button.
– Buttons can be composed of different child
widgets for different characteristics.
Buttons
• Following are the different types of button available
in Flutter.
Flat Button
Raised Button
Floating Button
Drop Down Button
Icon Button
Inkwell Button
PopupMenu Button
Outline Button
Flat Button
• It is a text label button that does not have much
decoration and displayed without any elevation.
• The flat button has two required properties
that are: child and onPressed(). It is mostly used
in toolbars, dialogs, or inline with other content.
• By default, the flat button has no color, and its
text is black. But, we can use color to the button
and text using color and textColor attributes,
respectively.
Raised Button
• It is a button, which is based on the material
widget and has a rectangular body.
• It is similar to a flat button, but it has an
elevation that will increases when the button is
pressed.
• It adds dimension to the UI along Z-axis. It has
several properties like text color, shape,
padding, button color, the color of a button
when disabled, animation time, elevation, etc.
Raised Button
• This button has two callback functions.
• onPressed(): It is triggered when the button is
pressed.
• onLongPress(): It is triggered when the button
is long pressed.
• It is to note that this button is in a disabled
state if onPressed() and onLongPressed()
callbacks are not specified.
Raised Button
• Example