这段代码有问题。列表中的每一项都是包含两列文本的行。正因为如此,即使在发布模式下,性能也会大幅下降。目前正在尝试为帖子构建一个Reddit风格的布局。使用行中嵌套的列会极大地降低性能。我的猜测是,这是因为Row和Column的大小本身是基于它们的子级的,所以嵌套它们会增加所需的大小计算。我只是不知道如何解决这个问题。
new ListView.builder(
controller: new ScrollController(initialScrollOffset: this.offset),
key: new UniqueKey(),
itemCount: this._posts != null ? this._posts.length : 0,
itemBuilder: (BuildContext context, int i) {
return new PostCard(
widget._posts[i],
);
},
),PostCard的返回如下所示(示例):
return new Container(
child: new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Column(
children: <Widget>[
new Text("Hello World"),
new Text("Hello World"),
new Text("Hello World"),
new Text("Hello World"),
],
),
new Column(
children: <Widget>[
new Text("Hello World"),
new Text("Hello World"),
new Text("Hello World"),
new Text("Hello World"),
],
),
],
),
);编辑:完整UI示例的屏幕截图。与上面的嵌套列示例相同级别的jank。
发布于 2018-06-02 08:37:46
更新。在其他手机上测试,问题不存在。问题只出现在我的特定手机上(7.0上的S7 Edge )。
https://stackoverflow.com/questions/50639313
复制相似问题