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'.

LogicalAnt
  • 907
  • 3
  • 12
  • 28
Sampath Wijesinghe
  • 789
  • 1
  • 11
  • 33

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 Wijesinghe
  • 789
  • 1
  • 11
  • 33
dhruvin prajapati
  • 184
  • 1
  • 3
  • 15
0

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

Nithesh
  • 206
  • 3
  • 8