Skip to main content

Posts

Showing posts with the label Flutter

Flutter BottomNavigationBar

BottomNavigationBar A material widget that's displayed at the bottom of an application. Which shows around three to five items and it includes labels and icons. BottomNavigationBar allows you to select one item at a time and quickly navigate to a given page. Properties of the BottomNavigationBar : items: It defines the list of BottomNavigationBar Items to display the bottom navigation bar. currentIndex: It determines the current active bottom navigation bar item on the screen. onTap: It is called when we tapped one of the items on the screen. iconSize: It is used to specify the size of all bottom navigation item icons. fixedColor: It is used to set the color of the selected item. If we have not set a color to the icon or title, it will be shown. type: It determines the layout and behavior of a bottom navigation bar. It behaves in two different ways that are:  1. fixed: Default it is fixed and If it is null, it will use fixed. 2. shifting: It will use shifting where w...

Flutter RadioButton and Checkbox

RadioButton Radio Button is a material widget that is used as an option button where the user can select only one option from a group of options. We can use it in cases where the user has to select a single value from a set of values. If one radio button is selected then we cannot select the other radio buttons in the same group. we are taking an example of gender selection. title : It is used to specify the radio button label. groupValue : It is used to specify the currently selected item for the radio button group. value : It specifies the backhand value, which is represented by a radio button. onChanged : It will be called whenever the user selects the radio button. ThemeData : You want to change the theme and give primary color and swatch color as a theme it will be used in the whole application. activeColor : When you select the radio button at that time color shows which is defined in the activeColor property. tileColor : This property ...

Dropdown In Flutter

Dropdown We use the Dropdown Button to display any Dropdown List item as we can change its style according to the requirement. We can customize the dropDown widget with given properties like background color, hint, items, and many more. Let’s see some of the properties of the dropdown button for example. 1. Items We will use this property to define items displayed in the dropdown list as text values. We can define the items directly or we can define using a list. Firstly we can see how to define items directly. We are declaring one global variable and set value 1 so in the dropDown value, we can not see an empty value. and with the use of DropdownMenuItem() we can see the value of that particular item. Let's see the example of how to use items directly:- The second way is to use items property as a list of values and set that values in the Text widget. 2. Value We will use value property to set the selected it...

Flutter SingleChildScrollView

What is SingleChildScrollView? To create a simple vertical ScrollView which can contain different types of widgets with different behavior we would use SingleChildScrollView Widget.SingleChildScrollView Widget is a box that can scroll a single widget. Widget In the below example code snippet we are creating a function called _createContainer() that accepts Color and text as an argument and it returns Container() widget with height: 200 pixels. We will reuse this widget many times in the Column. Without SingleChildScrollView Now we are creating a Column widget and add some containers to it with the use of creating widget function _createContainer(). If you run this code snippet in your app, the column will look like this as shown in the image below. With SingleChildScrollView Now we are wrapping the Column widget with a SingleChildScrollView scrolling widget, the information on the page should scroll and not showing any error. If you run this code snippet in your app, the colu...

Master In Flutter ListViews

  What is ListView? ListViews are common in UI frameworks and are one of the most popular UI widgets. ListView is used to group several items in an array and display them in a scrollable list and the list can be scrolled vertically and horizontally. Here we are discussing two types of a listview with detailed examples and explanations. 1. Static ListView If you have a shortlist of items and the value of items and they are not changing in the future and static, then you can use the default ListView constructor to make it. Let's take an example in which we are defining the names of the days. In Listview we have ListTile widget which we can use as same as text widget in that we are showing the name of days and this is static so we have to define the length of the list for that we are using itemcount  property.   Horizontal ListView Default list view gives a scroll direction verticle if you want horizontal listview then you need to add property scroll direction is horizon...

Flutter Images

Images We are going to know about how to add images in flutter application. A flutter app when built has both assets and code. Assets mean resources that are available and deployed during runtime. The asset is a file that can include static data, configuration files, icons, and images offline and also online. The Flutter app supports many image formats such as JPEG, WebP, PNG, GIF, animated WebP/GIF, and many more. We can add images in multiple ways here we are discussing two ways that are mainly used in the flutter. Image.assets When you have to set the images statically and display them in the app, you can use Image.assets() function. 1. Add an Image to the new folder The new folder is should be at the root of your flutter project. You can name it as per your preference, but assets are preferred. If you want to add other assets to your app, like fonts then it is preferred to make another subfolder named fonts, images. 2. Set image path Now you can copy your image to the images sub-fo...

Types of Buttons In Flutter

Flutter Buttons Flutter has various types of buttons. Buttons are the Flutter widgets, which are a part of the material design library. So, here We are going to discuss different types of buttons and they can be placed anywhere in our UI as dialogs, forms, cards, and toolbars, AppBar and in many more places. Types of Flutter Buttons  1. TextButton Text Button is a Material Design button that comes without border or elevation change by default.TextButton is the replacement for FlatButton. We are clicking on TextButton then it is the same as Text and click effect if we want the Shadow, ButtonStyle, alignment, padding, and many more properties we can use as per our requirements. There are two required parameters. Of course, you have to pass a Widget as a child and onPressed. Taking an example that has text, style, and onPressed properties in style there are many properties we can customize like primary color, background color, surface, shape, and many more.  For defining a style ...