'Flutter- Wrap widget takes a long time to display children contained in a for loop
Wrap widget takes a long time to display these children contained in a for loop, Is there a solution to reduce this waiting time?
SingleChildScrollView(
padding: EdgeInsets.only(left: 10, right: 10),
child: Wrap(
direction: Axis.horizontal,
children: [
for (int i = 0; i < state.items.length; i++)
Expanded(
child: InkWell(
onTap: () {},
child: Container(
width: (MediaQuery.of(context).size.width - 40) / 3,
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
children: [
FadeInImage.assetNetwork(
fit: BoxFit.fill,
placeholder: 'assets/loading.gif',
image: state.items[i].image)),
.....
Solution 1:[1]
try to display shimmer or circular loading than show assetNetwork. after image/data loaded, show the the real widget.
Solution 2:[2]
use List.generate instead of for loop.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | anggadaz |
| Solution 2 | Kishan Busa |
