Flutter ListView继续执行将来的功能

时间:2019-08-22 19:22:35

标签: listview flutter lag

仅当我向上滚动时,我的ListView才很慢。我的列表视图是FurureBuilder的子级。我尝试了addAutomaticKeepAlives:true,因为我的数据是静态的,但似乎没有任何变化。

请帮助我 当我向上滚动时,scoll突然跳了起来。 展示视频的视频:https://streamable.com/1cjg3

class NavigatePageState extends State<NavigatePage> with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: Center(
        child: FutureBuilder(
          future: getPrincipalList(),
          builder: (context, snapshot) {
            if (snapshot.data == null) {
              return Column(
                children: <Widget>[
                  Center(
                    child: Text('Loading...') ,
                  )
                  ,
                  Container(
                    margin: EdgeInsets.only(top:100),
                    child: PlatformCircularProgressIndicator(
                      android: (_) => MaterialProgressIndicatorData(),
                      ios: (_) => CupertinoProgressIndicatorData(),
                    ),
                  )
                ],
              );
            } else {
              return ListView.builder(
                addAutomaticKeepAlives: true,
                addRepaintBoundaries: false,
                shrinkWrap: true,
                physics: BouncingScrollPhysics(),
                itemCount: snapshot.data.result.length,

                itemBuilder: (context, rowInt) {
                  return Column(
                    children: <Widget>[
                      Container(
                          child: sliderOfSongs(
                        topName: snapshot.data.result[rowInt].infoDetail.name,
                        topDescription:
                            snapshot.data.result[rowInt].infoDetail.description,
                        collectionName: snapshot
                            .data.result[rowInt].infoDetail.collectionName,
                        topIndex: rowInt,
                      )),
                      Divider(
                        color: Colors.blueGrey,
                        indent: 120,
                        endIndent: 120,
                      )
                    ],
                  );
                },
              );
            }
          },
        ),
      ),
      navigationBar: CupertinoNavigationBar(
        middle: Text('Navigate'),
      ),
    );
  }
  @override
  bool get wantKeepAlive => true;
}

0 个答案:

没有答案