gpt4 book ai didi

flutter - 动态 ListView 内的 ListView(分页)

转载 作者:行者123 更新时间:2023-12-03 02:47:38 24 4
gpt4 key购买 nike

我对 Flutter 还是很陌生,我正在尝试创建一个评论列表部分,子评论可以嵌套在父评论中。

我所做的是在动态 ListView 中创建一个 ListView,在这种情况下,我使用第 3 方库 PagewiseListView 进行延迟加载。但是在构建列表时出现了一些错误。

 @override
Widget build(BuildContext context) {
return Scaffold(
body: pageWiseBuilder(context, _story.kids ?? [], PAGE_SIZE),
);
}

Widget pageWiseBuilder(BuildContext context, List<int> list, int pageSize) {
if (list != null && list.length > 0) {
return PagewiseListView(
padding: EdgeInsets.all(15.0),
pageSize: pageSize,
itemBuilder: this.itemBuilder,
pageFuture: (pageIndex) =>
_repository.fetchComments(list, pageIndex * pageSize, pageSize),
);
} else {
return Container();
}
}

Widget itemBuilder(BuildContext context, Comment entry, int index) {
return Column(
children: <Widget>[
ListTile(
title: Text(entry.by ??= ""),
subtitle: Html(
data: unescape.convert(entry.text ??= ""),
useRichText: true,
onLinkTap: (url) {
_launchURL(url);
},
showImages: true,
renderNewlines: true,
),
),
Divider(),
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: SizedBox(height: 200.0,
child: ListView.builder(
physics: ClampingScrollPhysics(),
shrinkWrap: true,
itemCount: 5,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(top: 8.0),
child: Text('Nested list item $index'),
);
},
),
),
),
],
),
],
);
}

I/flutter ( 885): Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.

I/flutter ( 885): Another exception was thrown: RenderBox was not laid out: RenderFlex#a1031 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

I/flutter ( 885): Another exception was thrown: RenderBox was not laid out: RenderFlex#11980 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

I/flutter ( 885): Another exception was thrown: RenderFlex children have non-zero flex but incoming height constraints are unbounded.

I/flutter ( 885): Another exception was thrown: RenderBox was not laid out: RenderFlex#a33b5 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

I/flutter ( 885): Another exception was thrown: RenderBox was not laid out: RenderFlex#48c2a relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

I/flutter ( 885): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#d6726 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

I/flutter ( 885): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 549 pos 12: 'child.hasSize': is not true.

I/flutter ( 885): Another exception was thrown: NoSuchMethodError: The method '>' was called on null.

I/flutter ( 885): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 549 pos 12: 'child.hasSize': is not true.

最佳答案

您的 ListView 必须用至少具有该高度的 Widget 包裹。

  Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[],
),
),

关于flutter - 动态 ListView 内的 ListView(分页),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56637176/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com