Flutter : Navigation and Routes
Flutter’s navigation and routing system When push() is called, the DetailScreen widget is placed on top of the HomeScreen widget like this: The previous screen ( HomeScreen ) is still part of the widget tree, so any State object associated with it stays around while DetailScreen is visible. Named routes Flutter also supports named routes, which are defined in the routes parameter on MaterialApp or CupertinoApp : Navigation Now when you want to navigate you’ll just use Navigator.pushNamed(context, feedRoute); This will navigate you to the FeedView. If we want to pass parameters to the Feed view that’a just a small little change. Let’s make our Feed view take in a String as a parameter. class Feed extends StatelessWidget { final String data; Feed(this.data); @override Widget build(BuildContext context) { return Scaffold( body: Center(child: Text('Feed: $data')), ); } } Add floating action button into your homeView and onPressed we’ll push the ...

Comments
Post a Comment