Solution: Navigation and Routing
Explore solutions to navigation challenges.
We'll cover the following...
Solutions
Great job on completing all the steps in the previous challenge! Feel free to compare your code solutions with the solutions below:
Press + to interact
IconButton(onPressed: () {// TODO-1: Return data from screen below// solutionNavigator.pop(context, shopItem.itemName);},icon: const Icon(Icons.arrow_back,size: 32,),),GestureDetector(// TODO-2: Display data received// solutiononTap: () async{var data = await Navigator.pushNamed(context, itemDetailRoute,arguments: shopList[index]);ScaffoldMessenger.of(context)..removeCurrentSnackBar()..showSnackBar(SnackBar(content: Text('$data')));},child: ItemCard(shopItem: shopList[index],),),ElevatedButton(onPressed: () {// TODO-3: Clear routes to first screen// solutionNavigator.popUntil(context, (route)=> route.isFirst);},...)
...