我是 Flutter 的新手,最近几天一直在练习 UI 构建。我的假音乐播放器应用程序的主页是由部分列表视图(新歌曲、最新歌曲、热门歌曲等)组成的。每个部分都有一个标题和另一个最近音乐的列表视图,如以下链接所示:使用列
这张照片是使用列而不是列表拍摄的。但当我到达屏幕底部时,该列就不再有用(正如它本来的意思)。所以我需要使用 ListView 来代替。然而,一旦我这样做,应用程序的主体上就没有任何显示。像这样:使用列表视图这是这部分代码:
class PageBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
alignment: Alignment.center,
padding: const EdgeInsets.fromLTRB(18.0, 0.0, 0.0, 0.0),
child: new ListView( // <-- If it's a column, it 'works'
children: [
new SectionTitle(title: 'Trending now'), // <-- Makes the section title
new Padding(padding: new EdgeInsets.all(4.0)), // <-- Add some space
new Expanded(child: new MusicsListView(musics: _trendingSongsList)), // <-- Makes the music List view
],
)
);
} …Run Code Online (Sandbox Code Playgroud)