Flutter pushplatter中的传递参数

Flutter pushplatter中的传递参数,flutter,navbar,Flutter,Navbar,我正在尝试在我的颤振项目中使用CurveBottomNavigatorBar 我用我的曲线。。。在主省道中,如下所示: class _BottomNavigatorBarState extends State<BottomNavigatorBar> { int selectedIndex = 0; final screen = [ HomeScreen(), CartScreen(), MyStore(), SettingScreen(),

我正在尝试在我的颤振项目中使用CurveBottomNavigatorBar

我用我的曲线。。。在主省道中,如下所示:

class _BottomNavigatorBarState extends State<BottomNavigatorBar> {
  int selectedIndex = 0;
  final screen = [
    HomeScreen(),
    CartScreen(),
    MyStore(),
    SettingScreen(),
  ];
  @override
  Widget build(BuildContext context) {
    int args = ModalRoute.of(context).settings.arguments;

    return Scaffold(
      body: screen[selectedIndex],
      bottomNavigationBar: CurvedNavigationBar(
        height: 55,
        backgroundColor: Colors.transparent,
        buttonBackgroundColor: Theme.of(context).accentColor,
        color: Theme.of(context).primaryColor,
        animationCurve: Curves.easeOutCubic,
        index: selectedIndex,
        items: <Widget>[
          // code here
        ],
        onTap: (index) {
          setState(() {
            args = selectedIndex;
            selectedIndex = index;
          });
        },
      ),
    );
  }
}
sp我就是这样做的,我知道这是错误的,因为它不起作用


请提供任何帮助并原谅我的英语不好:(

您有一个参数
arguments
,您可以将其传递到
pushReplacementName

Future pushReplacementNamed(
构建上下文上下文,
字符串routeName,
{
结果呢,,
对象?参数,
}
)
你可以这样称呼它:

class _BottomNavigatorBarState extends State<BottomNavigatorBar> {
  int selectedIndex = 0;
  final screen = [
    HomeScreen(),
    CartScreen(),
    MyStore(),
    SettingScreen(),
  ];
  @override
  Widget build(BuildContext context) {
    int args = ModalRoute.of(context).settings.arguments;

    return Scaffold(
      body: screen[selectedIndex],
      bottomNavigationBar: CurvedNavigationBar(
        height: 55,
        backgroundColor: Colors.transparent,
        buttonBackgroundColor: Theme.of(context).accentColor,
        color: Theme.of(context).primaryColor,
        animationCurve: Curves.easeOutCubic,
        index: selectedIndex,
        items: <Widget>[
          // code here
        ],
        onTap: (index) {
          setState(() {
            args = selectedIndex;
            selectedIndex = index;
          });
        },
      ),
    );
  }
}
//考虑一个名为my\u args\u obj的变量
Navigator.of(context.pushReplacementNamed('/myStore',参数:my_args_obj);
然后,要从您的页面获取它:

final args=ModalRoute.of(context.settings.arguments);
请参考以下内容:

将接受参数的MyStore()小部件设置为

int索引;

MyStore(this.Index)
然后在屏幕上使用

widget.Index

请浏览上面的链接一次。

您不需要删除HomeScreen、CartScreen、MyStore和SettingScreen的路径,因为这些都是底部导航栏上的页面。如果您想要底部导航栏,您需要导航到它。我知道如何使用参数,但如果您能帮助我编辑我的p,我不知道应该如何使用它如果你能帮我编辑我的帖子
widget.Index