Flutter: Navigator operation requested with a context that does not include a Navigator - flutter

when I click ElevatedButton(), Navigator.push() occurs Error: Navigator operation requested with a context that does not include a Navigator. But I make that ElevatedButton() in other dart file as widget, and I import It. It works well. What's the difference betweent make navigator button inside in code and import navigator button.
class GuideMainScreen extends StatelessWidget {
GuideMainScreen({super.key});
final _controller = PageController();
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: const Color(0xFFF4EDDB),
appBar: const AppbarSkip(),
body: Column(
children: [
SizedBox(
height: 570,
child: PageView(
controller: _controller,
children: const [
GuideHowScreen(),
GuideFocusScreen(),
GuideBreakScreen(),
],
),
),
Row(
children: [
const Padding(padding: EdgeInsets.only(left: 40)),
SmoothPageIndicator(
controller: _controller,
count: 3,
effect: const ExpandingDotsEffect(
activeDotColor: Color(0xFFE7626C),
dotColor: Color(
0xFF232B55,
),
),
),
const SizedBox()
],
),
const Padding(
padding: EdgeInsets.symmetric(
vertical: 45,
),
),
const SizedBox(
width: 181,
height: 49,
// Error
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
);
},
child: const Text(
'SKIP',
style: TextStyle(color: Colors.white),
),
);
// Works Well
child: SkipButton(),
),
],
),
),
);
}
}
this is SkiptButton() Widget which I write code in other dart file
import 'package:flutter/material.dart';
class SkipButton extends StatelessWidget {
const SkipButton({super.key});
#override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen(),
),
);
},
child: const Text(
'SKIP',
style: TextStyle(color: Colors.white),
),
);
}
}

Related

Flutter Unexpected error, opens Heros.dart file

In my app there is 3 button.
Among them Login and Register button is working on onPressed but Settings Button (...) is not working. Once I click settings button I get this error.
Here is my Navigator code
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return const SettingsPage();
},
),
);
},
child: const Text(
'...',
style: TextStyle(fontSize: 25),
),
),
This is my entire screen including emulator.
Here is my WelcomePage full code.
import 'package:flutter/material.dart';
import 'package:test_app_2nd/login_page.dart';
import 'package:test_app_2nd/register_page.dart';
import 'package:test_app_2nd/settings.dart';
class WelcomePage extends StatefulWidget {
const WelcomePage({super.key});
#override
State<WelcomePage> createState() => _WelcomePage();
}
class _WelcomePage extends State<WelcomePage> {
#override
Widget build(BuildContext context) {
return Material(
child: Scaffold(
appBar: AppBar(
title: const Text('Welcome'),
centerTitle: true,
backgroundColor: Colors.red,
),
backgroundColor: Colors.white,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('images/flame-sign-in.png'),
const SizedBox(
height: 35.0,
),
const SizedBox(
height: 30.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) {
return const LoginPage();
}));
},
child: const Text('Login'),
),
const SizedBox(
width: 55.0,
),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return const RegisterPage();
},
),
);
},
child: const Text('Register'),
),
],
),
const SizedBox(
height: 35.0,
),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return const SettingsPage();
},
),
);
},
child: const Text(
'...',
style: TextStyle(fontSize: 25),
),
),
],
),
),
);
}
}
Here is my settings page full code:
import 'package:flutter/material.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
#override
State<SettingsPage> createState() => _SettingsPageState();
}
String imagePath1 = 'images/flame-4.png';
String imagePath2 = 'images/flame-134.png';
String currentImagePath = imagePath1;
class _SettingsPageState extends State<SettingsPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
actions: [
FloatingActionButton(
onPressed: () {},
child: const Icon(
Icons.add,
),
),
const SizedBox(
width: 5,
),
FloatingActionButton(
onPressed: () {},
child: const Text(
'...',
style: TextStyle(fontSize: 20.0),
),
)
],
),
drawerEnableOpenDragGesture: false,
backgroundColor: Colors.white,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
setState(() {
if (currentImagePath == imagePath1) {
currentImagePath = imagePath2;
} else {
currentImagePath = imagePath1;
}
});
},
child: const Text('Click Me'),
),
Image.asset(currentImagePath),
],
),
),
);
}
}
Here is my error page screen shoot:

Getting error while using onTap function to navigate from a Card to a new page

I'm really new to flutter and coding in general. I want to create an app to aid in Pharmacology classes. The central question is, I want to click on a Card, and this card will lead me to a new page. However, when I programmed to function, It is returned an error. I can't find where is the error. Can anyone help me?
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Farmacologia Odontológica',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: const Splash(),
);
}
}
class Splash extends StatefulWidget {
const Splash({Key? key}) : super(key: key);
#override
State<Splash> createState() => _SplashState();
}
class _SplashState extends State<Splash> {
#override
void initState() {
// TODO: implement initState
super.initState();
Future.delayed(const Duration(seconds: 2), () {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => const HomePage()));
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('icons/Pilulas.png', height: 230,width: 230,),
const SizedBox(height: 30,),
if (Platform.isIOS)
const CupertinoActivityIndicator(
radius: 15,
)
else
const CircularProgressIndicator(
color: Colors.white,
)
],
),
),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
centerTitle: true,
title: Text('Farmacologia Odontológica',style: TextStyle(
fontFamily: 'fonts/Quicksand-Light.ttf',
fontSize: 22,
),),
),
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(padding: const EdgeInsets.only(top:10,bottom: 10),),
Text('Classes de Medicamentos', textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'fonts/Quicksand-Medium.ttf',
fontSize: 18,
)),
(GestureDetector(onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => analgesicos()),
)
),
child: const Material(
child: (
Card(
child: ListTile(
title: const Text('Analgésicos'),),)
),
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Anti-inflamatórios'),
),
)
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Antibióticos'),
),
)
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Antifúngicos'),
),
)
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Antivirais'),
),
)
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Anti-histamínicos'),
),
)
),
),
const Material(
child: (
Card(
child: ListTile(
title: const Text('Ansiolíticos'),
),
)
),
)
]
),
),
);
}
}
There is a parenthesis issue on GestureDetector
closing,
GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => analgesicos(),
),
), // issue was here
child: const Material(
child: Card(
child: ListTile(
title: const Text('Analgésicos'),
),
),
),
),
use below snippet
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
centerTitle: true,
title: Text(
'Farmacologia Odontológica',
style: TextStyle(
fontFamily: 'fonts/Quicksand-Light.ttf',
fontSize: 22,
),
),
),
body: Container(
child:
Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
Padding(
padding: const EdgeInsets.only(top: 10, bottom: 10),
),
Text('Classes de Medicamentos',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'fonts/Quicksand-Medium.ttf',
fontSize: 18,
)),
GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => analgesicos(),
),
), // issue was here
child: const Material(
child: Card(
child: ListTile(
title: const Text('Analgésicos'),
),
),
),
),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => analgesicos(),
),
);
},
child: Card(
child: ListTile(
title: const Text('Anti-inflamatórios'),
),
),
),
InkWell(
onLongPress: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => analgesicos(),
),
);
},
child: Card(
child: ListTile(
title: const Text('Antibióticos'),
),
),
),
Card(
child: ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => analgesicos(),
),
);
},
title: const Text('Antifúngicos'),
),
),
const Material(
child: (Card(
child: ListTile(
title: const Text('Antivirais'),
),
)),
),
const Material(
child: (Card(
child: ListTile(
title: const Text('Anti-histamínicos'),
),
)),
),
const Material(
child: (Card(
child: ListTile(
title: const Text('Ansiolíticos'),
),
)),
)
]),
),
);
}
}
I've included 3 ways of using tap event
GestureDetector
InkWell
ListTile's onTap

Adding an Icon to a List using a button and actively updating UI using Provider state management

I want to add an Icon to a List following UI update using flutter Provider state Management.
I was successful to add an Icon using the floating button and confirm the result by printing the new List length. This ensures the addition of an Icon to a List but it does not update the UI for the new added Icon. Snippets are below
#override
_MedicalCosmeticsDetailsPageState createState() =>
_MedicalCosmeticsDetailsPageState();
}
class _MedicalCosmeticsDetailsPageState
extends State<MedicalCosmeticsDetailsPage> {
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return ChangeNotifierProvider<GridIcons>(
create: (context) => GridIcons(),
child: SafeArea(
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
iconTheme: IconThemeData(color: Colors.purple),
title: Text(
'xyz',
style: TextStyle(color: Colors.purple),
),
backgroundColor: Colors.transparent,
elevation: size.width * 0.05,
actions: [
Padding(
padding: EdgeInsets.only(right: size.width * 0.01),
child: IconButton(
icon: Icon(
Icons.search,
),
onPressed: () {},
),
),
],
),
body: GridViewPage(),
floatingActionButton: Consumer<GridIcons>(
builder: (context, myIcons, _) {
return FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print(myIcons.iconList.length);
myIcons.addIcon();
},
);
},
),
),
),
);
}
}
```//floating button for adding an ICON
```class GridIcons with ChangeNotifier {
List<IconData> iconList = [
Icons.ac_unit,
Icons.search,
Icons.arrow_back,
Icons.hdr_on_sharp,
];
addIcon<IconData>() {
iconList.add(Icons.sentiment_dissatisfied);
notifyListeners();
}
getIconList<IconData>() {
return iconList;
}
}
```//Function for icon addition
class GridViewPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
List _iconList = GridIcons().getIconList();
return ChangeNotifierProvider<GridIcons>(
create: (context) => GridIcons(),
child: Consumer<GridIcons>(
builder: (context, myIcon, child) {
return GridView.builder(
itemCount: _iconList.length,
padding: EdgeInsets.all(8.0),
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 250.0),
itemBuilder: (BuildContext context, int index) {
print('_buildGridViewBuilder $index');
return Card(
color: Colors.purple.shade300,
margin: EdgeInsets.all(8.0),
child: InkWell(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
_iconList[index],
size: 48.0,
color: Colors.purple.shade100,
),
Divider(),
Text(
'Index $index',
textAlign: TextAlign.center,
style: GoogleFonts.dmSans(
fontSize: 16,
color: Colors.white,
),
),
],
),
onTap: () {
print('Row: $index');
},
),
);
},
);
},
),
);
}
}
The icon doesn't appear in the UI although an icon is added to the Icon List.
You can copy paste run full code below
Step 1: In GridViewPage, you do not need ChangeNotifierProvider
Step 2: remove List _iconList = GridIcons().getIconList();
Step 3: use myIcon.iconList.length and myIcon.iconList[index]
code snippet
class GridViewPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
//List _iconList = GridIcons().getIconList();
return Consumer<GridIcons>(
builder: (context, myIcon, child) {
return GridView.builder(
itemCount: myIcon.iconList.length,
...
Icon(
myIcon.iconList[index],
size: 48.0,
working demo
full code
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
class MedicalCosmeticsDetailsPage extends StatefulWidget {
#override
_MedicalCosmeticsDetailsPageState createState() =>
_MedicalCosmeticsDetailsPageState();
}
class _MedicalCosmeticsDetailsPageState
extends State<MedicalCosmeticsDetailsPage> {
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return ChangeNotifierProvider<GridIcons>(
create: (context) => GridIcons(),
child: SafeArea(
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: true,
iconTheme: IconThemeData(color: Colors.purple),
title: Text(
'xyz',
style: TextStyle(color: Colors.purple),
),
backgroundColor: Colors.transparent,
elevation: size.width * 0.05,
actions: [
Padding(
padding: EdgeInsets.only(right: size.width * 0.01),
child: IconButton(
icon: Icon(
Icons.search,
),
onPressed: () {},
),
),
],
),
body: GridViewPage(),
floatingActionButton: Consumer<GridIcons>(
builder: (context, myIcons, _) {
return FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
print(myIcons.iconList.length);
myIcons.addIcon();
},
);
},
),
),
),
);
}
}
class GridIcons with ChangeNotifier {
List<IconData> iconList = [
Icons.ac_unit,
Icons.search,
Icons.arrow_back,
Icons.hdr_on_sharp,
];
addIcon<IconData>() {
iconList.add(Icons.sentiment_dissatisfied);
notifyListeners();
}
getIconList<IconData>() {
return iconList;
}
}
class GridViewPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
//List _iconList = GridIcons().getIconList();
return Consumer<GridIcons>(
builder: (context, myIcon, child) {
return GridView.builder(
itemCount: myIcon.iconList.length,
padding: EdgeInsets.all(8.0),
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 250.0),
itemBuilder: (BuildContext context, int index) {
print('_buildGridViewBuilder $index');
return Card(
color: Colors.purple.shade300,
margin: EdgeInsets.all(8.0),
child: InkWell(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
myIcon.iconList[index],
size: 48.0,
color: Colors.purple.shade100,
),
Divider(),
Text(
'Index $index',
textAlign: TextAlign.center,
style: GoogleFonts.dmSans(
fontSize: 16,
color: Colors.white,
),
),
],
),
onTap: () {
print('Row: $index');
},
),
);
},
);
},
);
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MedicalCosmeticsDetailsPage());
}
}

Navigator operation requested with a context that does not include a Navigator - Flutter

i have a problem with navigator in my flutter file.
The problem is in my GestureDetector in _listItem, after tap on object, in my debug console throw me:
The following assertion was thrown while handling a gesture:
Navigator operation requested with a context that does not include a Navigator.
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
I don't have idea why this not work for me, can abybody help me?
below is my code:
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return MaterialApp(
home:Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(100.0),
child: AppBar(
iconTheme: IconThemeData(color: Color.fromRGBO(9, 133, 46, 100)),
backgroundColor: Colors.white,
actions: <Widget>[
IconButton(
icon: Icon(
Icons.shopping_cart,
color: Color.fromRGBO(9, 133, 46, 100),
),
onPressed: (){
print('klikniete');
},
),
],
),
),
body: Builder(
builder: (context) => Container(
child: FutureBuilder(
future: fetchOrders(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (_ordersForDisplay.length == null) {
return Container(
child: Center(child: Text("Ładowanie...")),
);
} else {
return ListView.builder(
itemCount: _ordersForDisplay.length + 1,
itemBuilder: (BuildContext context, int index) {
return index == 0 ? _searchBar() : _listItem(index - 1);
},
);
}
},
),
),
),
)
);
}
_listItem(index) {
return GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => DetailPage(item: _ordersForDisplay[index])),
),
child: Card(
child: Padding(
padding: const EdgeInsets.only(
top: 32.0, bottom: 32.0, left: 16.0, right: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_ordersForDisplay[index].firstName,
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
),
Text(
_ordersForDisplay[index].lastName,
style: TextStyle(
color: Colors.grey.shade600
),
),
],
),
),
),
);
}
}
class DetailPage extends StatelessWidget {
final Order item;
const DetailPage({this.item});
#override
Widget build(BuildContext context) {
return Center(
child: Text('${item.firstName} - ${item.lastName}')
);
}
}
Try changing your methods args as.
_listItem(index, context) { //Changes here
....
}
And pass the context where you called it.
return index == 0 ? _searchBar() : _listItem(index - 1,context);

"Undefined name 'context'. Try correcting the name to one that is defined, or defining the name." Flutter

This is a snippet of my widgets.dart file where I defined a widget called see_all_cards and its only purpose is to show an extended list of all cards that I was initially displaying. It should just redirect to Trending.dart. That's my main goal here.
Widget see_all_cards(){
return Container(
child: FlatButton(
child: Text(
"See all (43)",
style: TextStyle(
color: Theme.of(context).accentColor, // error
),
),
onPressed: (){
Navigator.push(
context, // error
MaterialPageRoute(
builder: (BuildContext context){
return trending();
},
),
);
},
)
);
}
The following segment is my main page. I've called SlowlyApp from void main.
class SlowlyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SlowlyApp',
home: Scaffold(
appBar: AppBar(
title: Text('Search',
style: TextStyle(
color: Color.fromRGBO(0,0,0,1),
),
),
backgroundColor: Color.fromRGBO(225,225,0,1),
actions: <Widget>[
IconButton(
icon:
Icon(Icons.search),
onPressed: (){
showSearch(context: context, delegate: data_search());
}
),
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
smallgap(),
current_cards_heading(),
current_cards(),
see_all_cards(),
smallgap(),
],
),
),
);
}
}
see_all_cards should expect context as parameter. You only have context in your main widget's build method
Widget see_all_cards(BuildContext context){
return Container(
child: FlatButton(
child: Text(
"See all (43)",
style: TextStyle(
color: Theme.of(context).accentColor, // error
),
),
onPressed: (){
Navigator.push(
context, // error
MaterialPageRoute(
builder: (BuildContext context){
return trending();
},
),
);
},
)
);
}
And then you can call passing the context.
class SlowlyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SlowlyApp',
home: Scaffold(
appBar: AppBar(
title: Text('Search',
style: TextStyle(
color: Color.fromRGBO(0,0,0,1),
),
),
backgroundColor: Color.fromRGBO(225,225,0,1),
actions: <Widget>[
IconButton(
icon:
Icon(Icons.search),
onPressed: (){
showSearch(context: context, delegate: data_search());
}
),
],
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
smallgap(),
current_cards_heading(),
current_cards(),
see_all_cards(context),
smallgap(),
],
),
),
);
}
}
I also get this error to solve this way
it's the main file container called my widgets _buildFoodItem define context with parameters
Container(
height: MediaQuery.of(context).size.height - 185.0,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(75.0),
),
),
child: ListView(
primary: true,
padding: const EdgeInsets.only(left: 25.0, right: 20.0),
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 45.0),
child: Container(
height: MediaQuery.of(context).size.height - 300.0,
child: ListView(children: [
_buildFoodItem(context, 'assets/images/plate1.png',
'Slazmon bowl', '₹ 150:00'),
_buildFoodItem(context, 'assets/images/plate2.png',
'Spring bowl', '₹ 120:00'),
_buildFoodItem(context, 'assets/images/plate3.png',
'Chikz bowl', '₹ 100:00'),
_buildFoodItem(context, 'assets/images/plate4.png',
'Berry Bowl', '₹ 199:00'),
_buildFoodItem(context, 'assets/images/plate5.png',
'Greezy bowl', '₹ 170:00'),
]),
),
)
],
),
),
this is my widget _buildFoodItem check the context
Widget _buildFoodItem(
BuildContext context, String imgPath, String foodName, String price) {
return Padding(padding: const EdgeInsets.only(
top: 10.0, left: 10.0, right: 10.0),
child: InkWell(
onTap: () {
Navigator.push(
context,
(MaterialPageRoute(
builder: (context) => FoodDetailsPage(
heroTag: imgPath,
foodName: foodName,
foodPrice: price,
),
)));
},
))
}
)