如今,我正在尝试实现一种非常常见的行为,即在另一个可滚动的小部件中放置一个水平列表。考虑一下像imdb应用程序的主屏幕这样的内容:
所以我想有一个垂直滚动的小部件,上面没有几个项目。在它的顶部应该有一个水平线ListView,后面跟着一些叫做的项目motivationCard。列表和卡片之间也有一些标题。
我在我的身上有这样的东西Widget:
@override
Widget build(BuildContext context) => BlocBuilder<HomeEvent, HomeState>(
bloc: _homeBloc,
builder: (BuildContext context, HomeState state) => Scaffold(
appBar: AppBar(),
body: Column(
children: <Widget>[
Text(
Strings.dailyTasks,
),
ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: tasks.length,
itemBuilder: (BuildContext context, int index) =>
taskCard(
taskNumber: index + 1,
taskTotal: tasks.length,
task: tasks[index],
),
),
Text(
Strings.motivations,
),
motivationCard(
motivation: Motivation(
title: 'Motivation 1',
description:
'this is a description of the motivation'),
),
motivationCard(
motivation: Motivation(
title: 'Motivation 2', …Run Code Online (Sandbox Code Playgroud) android listview horizontal-scrolling flutter flutter-layout