This post is part of my 100DaysOfCode series. In this series, I write about what I am learning on the 100DaysOfCode challenge. For this challenge, I will be learning flutter and firebase by building an Agriculture Management Information System.
On Day 21 we mainly discussed the difficulty I had with writing widget tests for my Flutter app.
In this post, we will discuss why using form fields as descendants of a Listview is a bad idea.
ListView is a scrolling widget that displays its children one by one. When a child is scrolled out of view, the associated element subtree, states and render objects are destroyed. The means that user input from widgets like TextFormField will be lost when the widget is scrolled out of view. While they are ways to keep state mentioned here, I prefer to use a SingleChildScrollView with a row or column as its child to accommodate multiple widgets as shown below.
SingleChildScrollView(child:Column(children:yourFormChildren)); solution from stackoverflow
In this post, we discussed why using form fields as descendants of a ListView is a bad idea.