【发布时间】:2021-09-18 20:55:34
【问题描述】:
我正在尝试制作银色应用栏,但遇到了问题。我使用 infitelist 来构建一个列表,因为我发现 infitelist 可以更巧妙地处理列表视图,因此应用程序栏不会像 Blow gif 中所示的那样位于顶部。由于不支持无限列表,我已经用容器包装了它。 下面是代码
SliverList(
delegate: SliverChildListDelegate(
<Widget>[
Container(
height: 500,
child: Column(
children: [
TopListView(posts: state.posts),
Expanded(
child: InfiniteList(
loadingBuilder: (context) {
return const SizedBox(
height: 100,
child: LoadingIndicator(
message: 'Fetching older posts',
),
);
},
hasError: state.status.isFailure,
isLoading: state.status.isLoading,
itemCount: state.posts.length,
hasReachedMax: state.hasReachedMax,
onFetchData: () {
context.read<PostsBloc>().add(const PostsRequested());
},
itemBuilder: (context, index) {
final post = state.posts[index];
return PostCard(post: post);
},
errorBuilder: (context) {
return SizedBox(
height: 100,
child: Center(
child: ReloadButton(
onPressed: () {
context
.read<PostsBloc>()
.add(const PostsRequested());
},
message: 'Failed to fetch more posts',
),
),
);
},
emptyBuilder: (context) {
return Center(
child: ReloadButton(
onPressed: () {
context
.read<PostsBloc>()
.add(const PostsRequested());
},
message: 'No Posts Found',
),
);
},
),
),
],
),
)
],
),
)
我们如何解决这个问题?
【问题讨论】:
标签: flutter flutter-layout flutter-animation