Flutter Development (Day-11):
- In the last post we have discussed about how to implement brand new Todo application.
- All source code : Click Here.
- Building its User Interface.
- How to display the data.
- How to remove the items from the List by tapping the Delete Icon or by Swiping it.
- Showing which item is deleted in the form of SnackBar.
- And finally modify some UI stuff.
- If you want to copy the exact same code click here.
- List _todos = []; First of all create a empty list which will be holding all of our Todo's.
- When we tap on the ADD button we have to perfom some operation see below.
- _validateForm() {if (_key.currentState.validate()) {setState(() {_todos.add(_controller.text);});_controller.clear();Navigator.of(context).pop();}}
- Here we have used setState() in order to refresh every single time of changing the data in the TextField and then we add the text to _todos list.
- Then we clear the data in the TextField and go back to homeScreen.
- Then we will build a ListView for displaying todos.
- Return a Card as parent widget and child will be ListTile which is having title,subtitle,leading and trailing properties.
- By using the index _todos[i] we will display the data on the homeScreen.
- When we press on the delete icon we will implement delete operation by
- onPressed: () { setState(() {_todos.removeAt(i);});
- Wrap the Card Widget by Dismissible in order to implement Swipe To Dismiss functionality.
- Dismissible widget requires a key which is of _todos[i] for knowing which item to dismiss.
- It will be used when we perform onDismissed method.Then show the snackbar by using Scaffold.
- Scaffold.of(context).showSnackBar(SnackBar(content: Text("Item ${i + 1} Is Deleted "),),);
- We can have a background property in which when the item is dismissed what to show in the background of the card widget.
- If you are following this tutorial / blog please leave your opinion 👀 / say Hii ✋/ Your e-mail in the comment section that I can improve myself and it will gives boost for me to do more tutorials.
- If you have any doubts feel free to ask me in the comment section or email me ramubugudi4@gmail.com I can definetly give reply.
Parkav InfoTech is Flutter app development in tamilnadu with Our experience team develop a flutter app to fulfil customer needs, launched in both android and iPhone platform.
ReplyDeleteVery interesting post...!
ReplyDeleteInformative content for students...
Top 5 Flutter Advantages & Disadvantages to Review in 2021
flutter app development services