【发布时间】:2022-11-30 01:32:14
【问题描述】:
我想问一下如何在 DefaultTab 中导航选项卡,我有 DefaultTabController 页面,我在 OrderList 中将其命名为 OrderList 我有 3 个不同的选项卡,当我单击按钮时,我想将其导航到显示取消页面的 OrderList .下面是我的代码。如果我直接导航到 OrderList,它将显示第一页,这是进度,我希望它导航到第三页,即取消页面。
class _OrderListState extends State<OrderList> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Container(
decoration: BoxDecoration(
color: Colors.teal[300],
),
child: Scaffold(
bottomNavigationBar: BottomNavigationBarForAppClient(indexNum: 1),
backgroundColor: Colors.transparent,
appBar: AppBar(
title: const Text('Order List'),
centerTitle: true,
flexibleSpace: Container(
decoration: BoxDecoration(
color: Colors.teal[300],
),
),
),
body: Column(
children: [
TabBar(tabs: [
Tab(
text: 'In Progress',
),
Tab(
text: 'Completed',
),
Tab(
text: 'Cancelled',
),
]),
Expanded(
child: TabBarView(children: [
ProgressClient(),
CompletedClient(),
CancelledClient(),
]),
)
],
),
),
),
);
}
}
这是其他页面代码。正如你在这里看到的,我将它导航到 OrderList() 和 OrderList Progress Client 中的默认选项卡,我希望它转到 Canceled Client 选项卡
IconButton(
onPressed: () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => OrderList()));
},
icon: Icon(Icons.arrow_back, size: 40, color: Colors.white)),
【问题讨论】:
-
它工作正常
-
是的,这段代码工作正常我有一个页面有一个按钮,我想将它导航到 Canceled Client(),但它导航到 Progress Client(),
-
试图更改来自
TabBarViewchildren 的选项卡? -
我更新了我的代码,你可以查看吗?
-
好的,我知道了,我会用回调方法分享帖子
标签: flutter navigation tabbar