返回下拉菜单其他值单击按钮(此下拉菜单位于另一页)
我有一个过滤下拉列表。我在另一页上有一个按钮。当我在另一个页面上单击此按钮时,如何返回到另一个页面上下拉菜单的其他选项?
DropdownPage
CustomDropdownButton<bool>(
hintText: "Select Filter",
value: controller.selectedFilter.value,
items: [
DropdownMenuItem<bool>(
child: Text("Sales"),
value: true,
),
DropdownMenuItem<bool>(
child: Text("Refunds"),
value: false,
)
],
onChanged: (bool selectedFilter) {
controller.selectedFilter.value = selectedFilter;
},
)
Otherpage(按钮在这里,此下拉菜单在另一页上)
Expanded(
child: ElevatedButton(
onPressed: () {
// return dropdown other value (this dropdown on another page).
},
child: Text("Update")),
)
谢谢,
I have one filtering dropdown. I have one button on another page. When I click this button on another page, how can I return to other options of the dropdown on the other page?
DropdownPage
CustomDropdownButton<bool>(
hintText: "Select Filter",
value: controller.selectedFilter.value,
items: [
DropdownMenuItem<bool>(
child: Text("Sales"),
value: true,
),
DropdownMenuItem<bool>(
child: Text("Refunds"),
value: false,
)
],
onChanged: (bool selectedFilter) {
controller.selectedFilter.value = selectedFilter;
},
)
Otherpage (button is here, this dropdown on another page)
Expanded(
child: ElevatedButton(
onPressed: () {
// return dropdown other value (this dropdown on another page).
},
child: Text("Update")),
)
Thank you,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您正在
ElevatedButton.onPressed
中导航到其他页面,您可以等待导航器并从
CustomDropdownButton
中阅读官方配方 https://docs.flutter.dev/cookbook/navigation/returning-data
Assuming you are navigating to your other page in
ElevatedButton.onPressed
you can await for the navagitorand from your
CustomDropdownButton
Read more about this from the official recipe https://docs.flutter.dev/cookbook/navigation/returning-data