有没有可能让颤振扩展的儿童成为网格视图?
目前我正在使用此代码获取ListView。
children : myData.map((data) {return MyWidget()}).toList()
我想让昂贵的孩子成为网格视图而不是列表视图。我正在制作一个购物应用程序,其中Expensionile是一个类别,我希望子类别的孩子成为GridView。
最佳答案
这是我的尝试:
SingleChildScrollView(
child: Column(children: <Widget>[
ExpansionTile(title: Text("Category 1"), children: <Widget>[
GridView.count(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
crossAxisCount: 2,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 10.0,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 4),
children: <Widget>[
Text("SubCategory 1"),
Text("SubCategory 2"),
Text("SubCategory 3"),
Text("SubCategory 4"),
Text("SubCategory 5"),
Text("SubCategory 6"),
])
]),
ExpansionTile(title: Text("Category 2"), children: <Widget>[
GridView.count(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
crossAxisCount: 2,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 10.0,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 4),
children: <Widget>[
Text("SubCategory 1"),
Text("SubCategory 2"),
Text("SubCategory 3"),
Text("SubCategory 4"),
Text("SubCategory 5"),
Text("SubCategory 6"),
])
]),
ExpansionTile(title: Text("Category 3"), children: <Widget>[
GridView.count(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
crossAxisCount: 2,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 10.0,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 4),
children: <Widget>[
Text("SubCategory 1"),
Text("SubCategory 2"),
Text("SubCategory 3"),
Text("SubCategory 4"),
Text("SubCategory 5"),
Text("SubCategory 6"),
])
])
]),
)
关于dictionary - Flutter ExpansionTile child 为Gridview?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53518596/