gpt4 book ai didi

flutter - 如何在 Flutter 中的 Column 内使用带有 ListView 的 Expansion Tile

转载 作者:行者123 更新时间:2023-12-02 19:39:53 26 4
gpt4 key购买 nike

我正在尝试创建一个自定义抽屉。

我想修复DrawerHeader。但是,我希望 ExpansionTileListView 可滚动。

/image/RdqFI.jpg ,

/image/dN0YN.jpg

 class _NavigationDrawerState extends State<NavigationDrawer> {


@override
Widget build(BuildContext context) {
return Drawer(
child: Column(
children: <Widget>[
DrawerHeader(
child: Column(....),
ExpansionTile(
title: Text('Roles'),
children: [
ListView.builder(
itemBuilder: _buildRolesList,
itemCount: roles.length,
shrinkWrap: true,
)
],
),
ListView.builder(
shrinkWrap: true,
itemBuilder: _buildList,
itemCount: myList.length,
),
],
),
);
}

Widget _buildList(BuildContext context, int index) {
return ListTile(
leading: Icon(icons[myList[index].toLowerCase()]),
title: Text(myList[index]),
);
}

Widget _buildRolesList(BuildContext context, int index) {
return ListTile(
dense: true,
title: Text(roles[index]),
onTap: () {},
);
}


}

最佳答案

试试这个:

class _NavigationDrawerState extends State<NavigationDrawer> {
@override
Widget build(BuildContext context) {
return Drawer(
child: Column(
children: <Widget>[
ExpansionTile(
title: Text('Roles'),
children: [
SizedBox(
height: MediaQuery.of(context).size.height - 100,
child: ListView.builder(
itemBuilder: _buildRolesList,
itemCount: roles.length,
shrinkWrap: true,
),
)
],
),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemBuilder: _buildList,
itemCount: myList.length,
),
),
],
),
);
}

Widget _buildList(BuildContext context, int index) {
return ListTile(
leading: Icon(icons[myList[index].toLowerCase()]),
title: Text(myList[index]),
);
}

Widget _buildRolesList(BuildContext context, int index) {
return ListTile(
dense: true,
title: Text(roles[index]),
onTap: () {},
);
}

关于flutter - 如何在 Flutter 中的 Column 内使用带有 ListView 的 Expansion Tile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60417960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com