我需要创建一个52x80的正方形方块网格。看起来像这样:
但是在仿真器中开发时性能特别慢(超过1s的“滞后”)。我了解Flutter代码在物理设备上的发布模式下运行得更快,在我的情况下,如果设备是新设备,也是如此。但是,如果设备使用了几年(例如,三星Galaxy S8或iPhone 8),则在加载视图和滚动时会有令人沮丧的明显时间。而且我不能那样发布我的应用程序。我正在这样构建我的GridView:
GridView.count(
shrinkWrap: true,
primary: false,
padding: const EdgeInsets.all(5.0),
crossAxisCount: 52,
crossAxisSpacing: 1.0,
mainAxisSpacing: 1.0,
addAutomaticKeepAlives: true,
children: blocks.map((block) => // blocks is just a list of 4160 objects
FlatButton(
child: null,
color: block.backgroundColor,
onPressed: () {
// open a new route
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent
)
).toList()
)
我已经尝试将FlatButton
换成Image
或SizedBox
,这会有所帮助。关于如何提高速度的任何建议?