Skip to main content

Posts

Showing posts from January, 2022

flutter - How to change PopupMenuButton icon

Flutter - PopupMenuButton Change Icon The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to set or change the PopupMenuButton widget’s icon. Here we used the PopupMenuButton class’s icon property to change the default icon of the PupupMenuButton widget. Here we also change the default color of the PopupMenuButton widget’s replaced icon. The PopupMenuButton class’s icon property value is a widget that is the icon used for this button and the button will behave like an Ic...

flutter - How to use PopupMenuItem onTap

Flutter - PopupMenuItem onTap The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to use the PopupMenuItem widget’s tap callback. Here we used the PopupMenuItem class’s onTap property to set the PupupMenuButton widget’s item tap callback. The flutter PopupMenuItem class represents an item in a material design popup menu. Normally the child of a PopupMenuItem is a Text widget. But the flutter developers can build more complex items such as they can show both an icon and ...

flutter - How to use PopupMenuButton onSelected

Flutter - PopupMenuButton onSelected The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to use the PopupMenuButton widget’s onSelected callback. Here we used the PopupMenuButton class’s onSelected property to set the PupupMenuButton widget’s item selection callback. The PopupMenuButton class’s onSelected property value is a PopupMenuItemSelected instance that is called when the user selects a value from the popup menu created by this button. But if the popup menu is dis...

flutter - How to show icon and text on PopupMenuButton items

Flutter - PopupMenuButton Icon & Text The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to display both a text and an icon on each item in a PopupMenuButton widget. Here we used the PopupMenuButton class’s itemBuilder property to add items to the PupupMenuButton widgets. And also configure the menu items to show text and an icon inside each item of the PopupMenuButton widget. The PopupMenuButton class’s itemBuilder property value is a PopupMenuItemBuilder instanc...

flutter - How to change PopupMenuButton items icon color

Flutter - PopupMenuButton Items Icon Color The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to display both a text and an icon on each item in a PopupMenuButton widget. And how to change the icon color of menu items in a PopupMenuButton widget by a single setting. Here we used the PopupMenuButton class’s itemBuilder property to add items to the PupupMenuButton widgets. And we wrapped the PopupMenuButton widget with a Theme widget to set or change a common color for the menu...

flutter - How to add divider to PopupMenuButton

Flutter - PopupMenuButton Divider The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to add a divider between PopupMenuButton items. Here we used the PopupMenuButton class’s itemBuilder property to add items to the PupupMenuButton widgets. And also add a divider line between each item by placing the PopupMenuDivider instance between items. The PopupMenuButton class’s itemBuilder property value is a PopupMenuItemBuilder instance. The PopupMenuItemBuilder is called when...

flutter - How to change PopupMenuButton offset

Flutter - PopupMenuButton Offset The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to set or change the offset value of a PopupMenuButton widget. Here we used the PopupMenuButton class’s offset property to set or change the PupupMenuButton widget’s default offset value. The PopupMenuButton class’s offset property value is an Offset instance that is the offset is applied relative to the initial position set by the position. If the flutter developers do not set the Popup...

flutter - How to change PopupMenuButton width

Flutter - PopupMenuButton Width The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to set or change the PopupMenuButton widget width. But there is no direct property or method to set or change the width of a PopupMenuButton widget. So we have to take help from another property of PopupMenuButton class. Here we used the PopupMenuButton class’s itemBuilder property to specify the width of PopupMenuButton items, this will finally change the width of the PopupMenuButton widge...

flutter - How to change PopupMenuButton shape

Flutter - PopupMenuButton Shape The PopupMenuButton class allows us to display a menu when pressed and calls onSelected when the menu is dismissed because an item was selected. The value passed to onSelected is the value of the selected menu item. The flutter developers can provide one of a child or an icon but not both. If developers provide an icon then PopupMenuButton behaves like an IconButton. If both child and icon are null, then a standard overflow icon is created depending on the platform. The following flutter app development tutorial will demonstrate how to set or change the PopupMenuButton widget shape. Here we used the PopupMenuButton class’s shape property to specify the shape of a PopupMenuButton widget. We rendered a rounded corners PopupMenuButton in this flutter example. The PopupMenuButton class’s shape property value is a ShapeBorder instance that defines the shape of the menu. When flutter developers leave the shape property...

flutter - How to use IconButton onPressed

Flutter - IconButton onPressed The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to use IconButton onPressed property. The IconButton onPressed property makes the button clickable when the developers set a value to it. If they pass a null value to this onPressed property value the button act as disable/nonclickable. Actually, the onPressed property is used to trigger an action when someone clicks the IconButton widget. The IconButton class’s onPressed property value is a callback that is called when the button is tapp...

flutter - How to disable an IconButton

Flutter - IconButton Disable The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to disable an IconButton widget. Here we will also set a color for the IconButton widget’s disabled state. The IconButton class’s onPressed property value is a callback that is called when the button is tapped or otherwise activated. When the flutter developers set this property value to null, the button will be disabled. So in this flutter example code, we passed a null value for the IconButton onPressed property to disable the IconButton ...

flutter - IconButton remove splash

Flutter - IconButton Remove Splash The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can also be used in many other places. The flutter app developers can leave the onPressed callback null to disable an IconButton, it will not react to touch. The following flutter app development tutorial will demonstrate how to remove the splash from an IconButton widget. In this example code, we used the IconButon class’s splashColor property to remove the splash effect of an InconButton widget. Here we also change the icon button’s highlight color by using the IconButton class’s highlightColor property. The IconButton class’s splashColor property value is a Color that defines the primary color of the button when the button is in the down/pressed state. Th...

flutter - How to remove IconButton padding

Flutter - IconButton Remove Padding The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can be used in many other places as well. The flutter app developers can leave the onPressed callback null to disable an IconButton, then it will not react to touch. The following flutter app development tutorial will demonstrate how to remove the padding from an IconButton widget. In this example code, we used the IconButon class’s padding property to remove the padding of an InconButton widget. Here we also change the icon button’s splash radius by using the IconButton class’s splashRadius property. The IconButton class’s padding property defines the padding around the button's icon. The entire padded icon will react to input gestures. The padding p...

flutter - How to change IconButton size

Flutter IconButton Size The IconButton class represents a material design icon button. IconButton is a picture printed on a material widget that reacts to touches by filling with color. The flutter developers commonly used the Icon buttons in the AppBar actions field, but IconButtons can be used in many other places as well. The flutter app developers can leave the onPressed callback null to disable an IconButton, then it will not react to touch. The following flutter app development tutorial will demonstrate how to set or change the IconButton widget size. Here we used the IconButton class’s iconSize property to change an IconButton widget’s size. The flutter developers must not override the icon's size with its Icon.size parameter when creating an IconButton widget. Instead, the flutter developers have to use the IconButton class’s iconSize parameter to set the IconButton widget’s size. The IconButton class’s iconSize property value is ...

flutter - How to create circular OutlinedButton

Flutter - Circular OutlinedButton The OutlinedButton class represents a material design outlined button that is essentially a TextButton with an outlined border. The outlined buttons are medium-emphasis buttons. In a flutter application, the OutlinedButtons contain actions that are important, but they are not the primary action in an app. An OutlinedButton widget’s default style is defined by defaultStyleOf. The flutter application developers can override the OutlinedButton’s style with its style parameter. An OutlinedButton has a default ButtonStyle.side which defines the appearance of the outline. The flutter app developers can specify an OutlinedButton's shape and the appearance of its outline by specifying both the ButtonStyle.shape and ButtonStyle.side properties. The following flutter application development tutorial will demonstrate how to create a circular OutlinedButton widget. Here we will use the OutlinedButton class’s styleFrom() static...

flutter - How to add padding to OutlinedButton

Flutter - OutlinedButton Padding The OutlinedButton class represents a material design outlined button that is essentially a TextButton with an outlined border. The outlined buttons are medium-emphasis buttons. In a flutter application, the OutlinedButtons contain actions that are important, but they are not the primary action in an app. An OutlinedButton widget’s default style is defined by defaultStyleOf. The flutter application developers can override the OutlinedButton’s style with its style parameter. An OutlinedButton has a default ButtonStyle.side which defines the appearance of the outline. The flutter app developers can specify an OutlinedButton's shape and the appearance of its outline by specifying both the ButtonStyle.shape and ButtonStyle.side properties. The following flutter application development tutorial will demonstrate how to add padding to an OutlinedButton widget. Here we will use the OutlinedButton class’s styleFrom() method ...

flutter - How to change OutlinedButton splash color

Flutter - OutlinedButton Splash Color The OutlinedButton class represents a material design outlined button that is essentially a TextButton with an outlined border. The outlined buttons are medium-emphasis buttons. In a flutter application, the OutlinedButtons contain actions that are important, but they are not the primary action in an app. An OutlinedButton widget’s default style is defined by defaultStyleOf. The flutter application developers can override the OutlinedButton’s style with its style parameter. An OutlinedButton has a default ButtonStyle.side which defines the appearance of the outline. The flutter app developers can specify an OutlinedButton's shape and the appearance of its outline by specifying both the ButtonStyle.shape and ButtonStyle.side properties. The following flutter application development tutorial will demonstrate how to set or change an OutlinedButton widget’s splash color. Here we will use the OutlinedButton class’s ...

flutter - How to change TextButton color

Flutter - TextButton Color The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or inline with other content. Text buttons do not have visible borders. The flutter developers should refrain from using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how to set or change the TextButton widget’s various colors. Here we will change the TextButton widget’s background color, text color/foreground color, and border color. In the below example code, we will use the TextButton class’s styleFrom() method to change the TextButton widget’s colors. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton c...

flutter - How to create a circular TextButton

Flutter - Circular TextButton The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can create a circular TextButton. That means we will make circle shaped TextButton. In the below example code, we will use the TextButton class’s styleFrom() method to create a circular TextButton widget. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns a ButtonStyle that doesn't override anything. ...

flutter - TextButton border radius only

Flutter - TextButton border radius for only specific corners The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can add only specified corners rounded-border to the TextButton. That means we will apply border radius for only specified corners, not all corners. In the below example code, we will use the TextButton class’s styleFrom() method to add specified corners rounded border around the TextButton widget. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle ...

flutter - How to create TextButton rounded border

Flutter - TextButton Rounded Border The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can add a rounded border to the TextButton. We will draw a solid colored rounded corners border around a TextButton. In the below example code, we will use the TextButton class’s styleFrom() method to add a rounded border around the TextButton widget. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns...

flutter - How to set TextButton width

Flutter - TextButton Width The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can set width of a TextButton. We will change the TextButton widget’s default width. Here we will use the TextButton class’s styleFrom() method to change the TextButton’s default width. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns a ButtonStyle that doesn't override anything. The ButtonStyle cl...

flutter - How to add a border to TextButton

Flutter - TextButton Border The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can add a border to the TextButton. We will draw a solid border around a TextButton. In the below example code, we will use the TextButton class’s styleFrom() method to add a border around the TextButton widget. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns a ButtonStyle that doesn't override anything. ...

flutter - How to add padding to TextButton

Flutter - TextButton Padding The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can add padding to a Text TextButton. That means how we can add padding to a TextButton widget’s all sides or any specific sides. In the below example code, we will use the TextButton class’s styleFrom() method to add padding to a TextButton widget. The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns a Button...

flutter - How to change TextButton size

Flutter - TextButton Size The TextButton class represents a material design text button. The flutter developers can use text buttons on toolbars, in dialogs, or in line with other content. Text buttons do not have visible borders. The flutter developers should avoid using text buttons where they would blend in with other content such as in the middle of lists. The TextButton style can be overridden with its style parameter. The following flutter application development tutorial will demonstrate how we can set the size of a TextButton. We will change the TextButton widget’s default width and height. In the below example code, we will use the TextButton class’s styleFrom() method to change the TextButton’s default width and height (size). The TextButton class’s styleFrom() method is a static convenience method that constructs a text button ButtonStyle given simple values. By default, TextButton class styleFrom() method returns a ButtonStyle that do...

flutter - How to remove padding from ElevatedButton

Flutter - ElevatedButton Remove Padding The ElevatedButton class represents a material design elevated button. The flutter developers can use elevated buttons to add dimension to otherwise mostly flat layouts such as in long busy lists of content, or in wide spaces. The flutter developers should avoid using elevated buttons on already-elevated content such as dialogs or cards. The flutter developers can override the ElevatedButton style with its style parameter. The static styleFrom() method is a convenient way to create an ElevatedButton ButtonStyle from simple values. The following flutter application development tutorial will demonstrate how we can remove the padding from an ElevatedButton widget. That means how we can remove the padding from an ElevatedButton widget’s all sides. Here we will use the ElevatedButton class’s styleFrom() method to remove the padding from an ElevatedButton widget. Actually, we will set the ElevatedButton’s padding val...

flutter - ElevatedButton border radius only

Flutter - ElevatedButton border radius only for specified corners The ElevatedButton class represents a material design elevated button. The flutter developers can use elevated buttons to add dimension to otherwise mostly flat layouts such as in long busy lists of content, or in wide spaces. The flutter developers should avoid using elevated buttons on already-elevated content such as dialogs or cards. The flutter developers can override the ElevatedButton style with its style parameter. The static styleFrom() method is a convenient way to create an ElevatedButton ButtonStyle from simple values. The following flutter application development tutorial will demonstrate how we can add only specified corners rounded-border to the ElevatedButton. That means we will apply the border radius for only the specified corners, not all the corners. Here we will use the ElevatedButton class’s styleFrom() method to add specified corners rounded border around the El...