I have a snapshotData
variable which contains the field author which is used in a searched bar to find book. I then have a widget searchedData which displays a list of books based on the author:
Widget searchedData() {
return ListView.builder(
itemCount: snapshotData.docs.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onDoubleTap: () {
Get.to(showBookDetails(),
transition: Transition.downToUp,
arguments: snapshotData.docs[index]);
},
child: ListTile(
leading: const Icon(Icons.account_circle),
title: Text(
snapshotData.docs[index]['Title'],
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 24.0),
),
subtitle: Text(
snapshotData.docs[index]['Author'],
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 24.0),
),
),
);
},
);
}
when someone double taps on a book in the GestureDetector i want to show another page which should display the book details specificly from the tappped book:
Widget showBookDetails() {
return Scaffold(
}
But when i double tap on a book i get error:
You are trying to use contextless navigation without
a GetMaterialApp or Get.key.
If you are testing your app, you can use:
[Get.testMode = true], or if you are running your app on
a physical device or emulator, you must exchange your [MaterialApp]
for a [GetMaterialApp].
How can i make sure that when i tap on a book in searchedData, i can display the book details in the widget showBookDetails?
EDIT
So i resolved the error mentioned by changing MaterialApp with GetMaterialApp in the main.dart. So i will close this post as solved and ask another question regarding how i can display the book details when tapping on a book
CodePudding user response:
You are using Get.to for navigation, change MaterialApp widget with GetMaterialApp. Probably it's in main.dart file.