Beginning App Development with Flutter by Rap Payne

Beginning App Development with Flutter by Rap Payne

Author:Rap Payne
Language: eng
Format: epub
ISBN: 9781484251812
Publisher: Apress


Stack navigation

If you’re an experienced developer, you’re familiar with queues and stacks. If not, let me explain briefly. Let’s say you work in a kitchen. As plates are cleaned, they’re stacked, right? Each plate is put on the top of the stack. This is called pushing onto the stack. When it is time to serve some food, you naturally take the last plate added, the one on top of the stack. This is called popping off the top of the stack.

Flutter’s navigation works with stacks. When you want to send the user to a new scene, you will push() a widget on the top of the stack and the user sees that widget. Each time you push(), you’re making the stack of scenes taller and taller. When you are ready for them to go back to where they were before, you’ll pop() the last scene off the top of the stack, and what is revealed? The previous scene.

With Flutter’s stack, you’ll typically predefine the scenes (aka routes) and give each a name. This must be done at the MaterialApp level like so:Widget build(BuildContext context) {

return MaterialApp(

title: 'Shopping App',

initialRoute: '/',

routes: {

'/': (BuildContext ctx) => LandingScene(),

'/browse': (BuildContext ctx) => Browse(),

'/product': (BuildContext ctx) => ViewProduct(),

'/checkout: (BuildContext ctx) => Checkout(),

},

);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.