Start a Project

Buttons In Flutter

Buttons In Flutter are the graphical control element that allows 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 In Flutter is a part of the material design library. Flutter provides several types of buttons that have different shapes, styles, and features.

You can also check out our Flutter app development services for more Flutter app development.

Features of Buttons

The standard features of a button in Flutter are given below:

  1. We can easily apply themes to buttons, shapes, colors, animation, and behavior.
  2. We can also theme icons and text inside the button.
  3. Buttons can be composed of different child widgets with different characteristics.

Types of Buttons in Flutter used now

Following are the different types of buttons available in Flutter:

1. Text Button

It is a text label button that does not have much decoration and is displayed without any elevation. The FlatButton is deprecated, now flutter uses the TextButton has two required properties that are: child and onPressed(). It is mostly used in toolbars, dialogs, or inline with other content. By default, the Text button has no color, and its text color depends on the theme color.

NOTE: We can add the icon also to the Text Button eg: TextButton.icon

2. Elevated Button

It is a button, which is based on the material widget and has a rectangular body. It is similar to a Text button, but it has an elevation that will increase when the button is pressed.

This button has Two callback functions for Use on the App end.

onPressed(): It is triggered when the button is pressed.

onLongPress(): It is triggered when the button is long pressed.

Styling for the elevated button is done using ElevatedButton.styleFrom

It is to be noted that this button is in a disabled state if onPressed() and onLongPressed() callbacks are not specified.

Here is the Code with its some Properties.

NOTE: Elevated Button also supports icon widgets eg: ElevatedButton.Icon()

3. Floating Action Button

A FAB button is a circular icon button that triggers the primary action in our application. It is the most used button in today’s applications. We can use this button for adding, refreshing, or sharing the content. Flutter suggests using at most one FAB button per screen. There are two types of Floating Action Button:

FloatingActionButton: It creates a simple circular floating button with a child widget inside it. It must have a child parameter to display a widget.

FloatingActionButton.extended: It creates a wide floating button along with an icon and a label inside it. Instead of a child, it uses labels and icon parameters.

NOTE: FloatingActionButton has more properties. Mainly we used FloatingAction Button within the scaffold Widget.

An Example for FloatingActionButton with Center Float.

4. Icon Button

An IconButton is a picture printed on the Material widget. It is a useful widget that gives the Flutter UI a material design feel. We can also customize the look and feel of this button. In simple terms, it is an icon that reacts when the user will touch it.

5. Outlined Button

It is similar to the Text button, but it contains a thin grey rounded rectangle border. Its outlined border is defined by the shape attribute.

6. InkWell Button

InkWell is the material widget in flutter. It responds to the touch action as performed by the user. There are so many gestures like double-tap, long press, tap down, etc. Below are the so many properties of this widget. We can set the radius of the inkwell widget using radius and also border-radius using borderRadius. We can give the splash color using splashColor and can do a lot of things.

NOTE: Visit Flutter’s official documentation for details of the InkWell_Button.

6. DropDown Button

A DropDownButton is a material design button. The DropDownButton is a widget that we can use to select one unique value from a set of values. It allows the user to select one value from some items. The default value shows the currently selected value. On clicking the DropDownButton it opens a list of items, from which the user can select the desired option.

NOTE: Visit Flutter’s official documentation for details of the DropDownButton.

7. Popup Menu Button

Popup menus are one of the most used widgets whether they be in a phone or a computer. The most common example of a popup menu would be when you right-click with your mouse and see some additional options of rename, delete, copy, paste.

That’s all for this Article.

Conclusion

We learned about some Buttons in Flutter in this blog.

Visit the link for additional information on the Buttons Widget in Flutter.

Thanks for reading this blog. You can also check other blogs from here for more knowledge.

Exit mobile version