I want to show a SnackBar Widget when the bottom tab is clicked. I am trying to show it as:
Scaffold.of(context).showSnackBar(new SnackBar(
cont
You do have a scaffold, but not above the context of MyHomePage.
Your Scaffold is a child of MyHomePage, while doing Scaffold.of(context)
is trying to access the closest parent Scaffold.
And since you have none, it crash.
You should probably wrap your BottomNavigationBar into a new class. And use that widget's context to do Scaffold.of(context)
.