【发布时间】:2025-12-07 10:45:01
【问题描述】:
我正在使用此代码打开带有参数的页面:
_modalBottomSheetMenu() {
wsModalBottom(
context,
title: trans(context, "Categories"),
bodyWidget: ListView.separated(
itemCount: _categories.length,
separatorBuilder: (cxt, i) => Divider(),
itemBuilder: (BuildContext context, int index) => ListTile(
title: Text(parseHtmlString(_categories[index].name)),
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(context, "/browse-category",
arguments: _categories[index])
.then((value) => setState(() {}));
},
),
),
);
}
但现在我只想直接在页面上设置参数。我试过这个,但它不起作用:
BrowseCategoryPage(key: 1),
我在浏览类别页面中得到了这个代码:
BrowseCategoryPage({Key key}) : super(key: key);
我能做些什么来解决这个问题?
【问题讨论】:
-
有任何理由使用命名路由吗?因为您可以轻松地在 Constructer 上传递值。