Flutter learning experience record

1. ListView dynamically displays records

      When using the ListView component, if it is a static list, you can use the List() method to initialize it directly, but if the children of the List point to a state that changes in real time, you need to use List.builder to create it, otherwise it will not be dynamically created when calling setState Refresh the list, the reference code is as follows:

ListView.builder(itemBuilder: (BuildContext context,int index){
              if(books.length>0 && index< books.length){
                String name = books[index]['name'];
                return ListTile(
                    title: Text(name),
                    onTap: () => clickBook(books[index]),
                );
              }else{
                return null;
              }

            })

 

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324085464&siteId=291194637