Skip to main content

Posts

Showing posts with the label Controller in flutter

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...

What is Controller in Flutter

What is Controller As per the name controller so our basic idea is something is controlled by this property but what? So, the answer is If you have an editable text widget then you need to store the value of that text somewhere. The simplest way is by setting a TextEditingController as the controller of a TextField. The value of the textField is updated with the use of this controller.  How to use the controller with the example:- We are taking an example to Retrieve the value of a text field that is entered by the user and that value is shown us in the snackbar Let's start with the following steps: 1. Create a TextEditingController To retrieve the text from the text field entered by the user, we create a TextEditingController and set it to a TextField or TextFormField. TextFormField is also working as TextField which we are discussing more in further blog with detail. Note: you need to call dispose of the method of the TextEditingController when you have finished using it and...