如何在颤抖上制作子类别
当我单击当前图片中出现的类别组(肥料,药物等)时,我将举一个例子,它将显示4个子类别,当然,当我再次按下时,它将关闭。如何以最方便的方式做到这一点?谢谢大家,
当我单击当前图片中出现的类别组(肥料,药物等)时,我将举一个例子,它将显示4个子类别,当然,当我按下时,它将关闭再一次。如何以最方便的方式做到这一点?谢谢大家提前
Container(
alignment: Alignment.center,
padding: EdgeInsets.only(left: Dimensions.width10),
child: Flex(
direction: Axis.horizontal,
children: [Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.el_makasi;
});
},
icon: Icon(
Icons.arrow_drop_down,
color:
_selectedPage == Page.el_makasi ? active : notActive,
),
label: const Text(
"Tohum",
style: TextStyle(color: AppColor.mainColor),
),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.gubre;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.gubre ? active : notActive,
),
label: const Text("Gübre",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.ilac;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.ilac ? active : notActive,
),
label: const Text("İlaç",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.tohum;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.tohum ? active : notActive,
),
label: const Text("Makineler",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.makine;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.makine ? active : notActive,
),
label: const Text("El makası",
style: TextStyle(color: AppColor.mainColor)),
),
],
),
),
),]
),
),
I am giving an example when I click on the category group (fertilizer, medicine, etc.) that appears in the current picture, it will show 4 sub-categories, of course, it will be closed when I press it again. How can I do this in the most convenient way? Thank you everyone in advance
I am giving an example when I click on the category group (fertilizer, medicine, etc.) that appears in the current picture, it will show 4 sub-categories, of course, it will be closed when I press it again. How can I do this in the most convenient way? Thank you everyone in advance
Container(
alignment: Alignment.center,
padding: EdgeInsets.only(left: Dimensions.width10),
child: Flex(
direction: Axis.horizontal,
children: [Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.el_makasi;
});
},
icon: Icon(
Icons.arrow_drop_down,
color:
_selectedPage == Page.el_makasi ? active : notActive,
),
label: const Text(
"Tohum",
style: TextStyle(color: AppColor.mainColor),
),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.gubre;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.gubre ? active : notActive,
),
label: const Text("Gübre",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.ilac;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.ilac ? active : notActive,
),
label: const Text("İlaç",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.tohum;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.tohum ? active : notActive,
),
label: const Text("Makineler",
style: TextStyle(color: AppColor.mainColor)),
),
TextButton.icon(
onPressed: () {
setState(() {
_selectedPage = Page.makine;
});
},
icon: Icon(
Icons.arrow_drop_down,
color: _selectedPage == Page.makine ? active : notActive,
),
label: const Text("El makası",
style: TextStyle(color: AppColor.mainColor)),
),
],
),
),
),]
),
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在页面中列出列表,然后在Onpressed中选择索引。
make a list within pages and select them with index in onPressed.
扩展是以有效方式进行此事情的最佳方法。
ExpansionTile is the best way to do this thing in an effective manner.