0

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

Create route

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

navigation to button click

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

It gives the error message as follows

Undefined name 'context'.

unreleased
  • 847
  • 2
  • 11
  • 23
sampath
  • 604
  • 1
  • 10
  • 30

2 Answers2

2

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

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

I think this will help you

sampath
  • 604
  • 1
  • 10
  • 30
0

You have to write onPressed() with in the class.

Nithesh
  • 198
  • 2
  • 8