I am curious how I would alter the app_router.dart file to allow for stacks of a single page type. When I try to just bring up a second instance of (for example) the grocery_item_screen.dart page it gives me the error that a “GlobalKey was used multiple times inside one widget’s child list”. How do I alter the GlobalKey to allow for a stack of the same page?
@abeswede i would add a new KEY parameter when you instantiate a new grocery_item_screen
. Currently the key is hardcoded.
static MaterialPage page({
GroceryItem? item,
int index = -1,
required Function(GroceryItem) onCreate,
required Function(GroceryItem, int) onUpdate,
}) {
return MaterialPage(
name: FooderlichPages.groceryItemDetails,
key: ValueKey(FooderlichPages.groceryItemDetails),
child: GroceryItemScreen(
originalItem: item,
index: index,
onCreate: onCreate,
onUpdate: onUpdate,
),
);
}
Might want to check the latest edition, which uses go_router 4
https://www.raywenderlich.com/books/flutter-apprentice