Closed mpigorini closed 4 years ago
Yess, you can update the list and give a key value to each child. This way the Flutter framework will understand what Widgets have been changed are which ones are new.
I suggest you use the countBuilder constructor if you have a lot of items.
StaggeredGridView.countBuilder(
crossAxisCount: 4,
itemCount: 8,
itemBuilder: (BuildContext context, int index) => new Container(
key: ValueKey('Item$indext'),
color: Colors.green,
child: new Center(
child: new CircleAvatar(
backgroundColor: Colors.white,
child: new Text('$index'),
),
)),
staggeredTileBuilder: (int index) =>
new StaggeredTile.count(2, index.isEven ? 2 : 1),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
)
Is possible add items dynamically with out refreshing all the grid view ?