
Clear Button: OnPressed will call _cityNameController.clear(), which will clear textField control.Second child is ButtonBar, which provides template for adding multiple buttons, I have created two RaisedButton, first one would clear content of the TextField and other button would add whatever text present in TextField into local list by name _lstText.decoration - This property would define UI of textfield, I provided labelText which is 'Add City' and filled as true.Here, we are passing class member _cityNameController. controller - This will act as object for setting and getting values from the screen.Since it could take multiple children, first children we would be adding would be of TextField, we have two properties of TextField here:.Don't worry if you don't understand it now, I would be writing a separate article for ListView, discussing all prominent properties and methods provided by it. Here, we have created a ListView control, it's a scrolling control, allowing you to put multiple widgets which could be scrolled vertically.Style: new TextStyle(fontWeight:FontWeight.bold),)) This widget is the root of your build(BuildContext context) ", Import ' package:flutter2_sfw/widgets/mainpage.dart'

Now in main.dart file under lib folder, delete everything and write the following code:.Once the project is created, following would be basic structure of the solution:.Please make sure Flutter bin path should be in your environment path variable. If using Visual Studio Code, use command flutter create flutter2_sfw in terminal window.
#Flutter buttonbar android
Open Android Studio and create a new flutter project by the name flutter2_sfw (short form for StateFulWidget).So let's dive in the application directly, here are the steps to follow, if you would like to make your hands dirty: Overall, the basic idea it to create a list of cities visited in app, this will show how StateFulWidget refreshes screen, when there is change in any value of the widget/class. ListView to persist whatever user input is.Add City button: to add user input in the list view.I am going to create a small mobile application which will contain the following things: We discuss about it more during this tutorial.


