颤振导航中未定义的名称“上下文" [英] Undefined name 'context' in flutter navigation

查看:29
本文介绍了颤振导航中未定义的名称“上下文"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个页面导航到另一个页面,我使用了以下代码

I want to navigate into one page to another an I used following code to that

创建路线

final routes = <String,WidgetBuilder> {
   DashboardIesl.tag : (context)=>DashboardIesl()
};

导航到按钮点击

onPressed: () {
  Navigator.push(context, new MaterialPageRoute(
    builder: (context) => new DashboardIesl()
  ));
},

它给出的错误信息如下

未定义名称上下文".

推荐答案

请给我看更多代码,上下文仅在有状态的小部件中可用,

please show me more code,context is only available in statefull widgets,

onPressed: () {  Navigator.push(
context,
MaterialPageRoute(builder: (context) => DashboardIesl()),  );}

我想这会对你有所帮助

这篇关于颤振导航中未定义的名称“上下文"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆