如何做滚动屏幕与很多小部件?



如何做滚动屏幕与许多小部件。我想使用carouselSlider,卡片,文本和listTile小部件。我使用listview与gridview,我得到了错误,我使用gridview,因为我想使用卡小部件并排和一个接一个。我英语不好,对不起

可以使用以下命令创建滚动屏幕:

return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
//Put the widget code you want here.
],
),
),
);

我希望这个答案对你有帮助。

将ListView作为父视图,GridView作为子视图,并使用如下的shrinkWrap true属性

ListView(
children: [
// First item in the ListView is a GridView
GridView.count(
shrinkWrap: true,
crossAxisCount: 2,
children: [
Container(
color: Colors.red,
height: 50,
width: 50,
),
Container(
color: Colors.blue,
height: 50,
width: 50,
),
Container(
color: Colors.green,
height: 50,
width: 50,
),
Container(
color: Colors.yellow,
height: 50,
width: 50,
),
],
),
// Second item in the ListView is a simple ListTile
ListTile(
title: Text('Item 2'),
),
// Third item in the ListView is another GridView
GridView.count(
shrinkWrap: true,
crossAxisCount: 3,
children: [
Container(
color: Colors.orange,
height: 50,
width: 50,
),
Container(
color: Colors.purple,
height: 50,
width: 50,
),
Container(
color: Colors.teal,
height: 50,
width: 50,
),
Container(
color: Colors.pink,
height: 50,
width: 50,
),
Container(
color: Colors.indigo,
height: 50,
width: 50,
),
Container(
color: Colors.brown,
height: 50,
width: 50,
),
],
),
// Fourth item in the ListView is another ListTile
ListTile(
title: Text('Item 4'),
),
],
);

最新更新