Navigator operation requested with a context that does not include a Navigator (Flutter)
140
Maybe you are not passing the Scaffold context to a separate widget and using it directly.
Either make a separate Widget for this ListTile
or wrap it with a Builder
as follow:
Builder(
builder: (context) => ListTile(
title: Text('Exercises'),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Exercises(),
),
);
},
),
),
Author by
heyheyhello
Updated on December 22, 2022Comments
-
heyheyhello over 1 year
I want to be able to navigate from Main.dart to Exercises.dart. When I tap on the List Tile in my App Drawer I get the following error:
Navigator operation requested with a context that does not include a Navigator.
Entire class
What seems to be the problem?
Thanks
-
heyheyhello almost 4 yearsive also imported exercises.dart to main.dart
-
Aadiyaara almost 4 yearsThis has something to do with where the Navigator is called, could u share the entire class?
-
heyheyhello almost 4 yearshi ive added the class as I have it
-