Navigation
Navigation
NAVIGATION
Navigation
• Navigation
• Drawer
Navigation:
- If your app consists of more than one screen, then you need to move between
them,How?
- Your application has a built in stack( LIFO ) = Last In First Out. If you move to another
screen then you have two choices:
1. Replace current screen with new screen.
2. Put new screen above old screen, so if you want to return back, you can do it
easily. How can you do that?
- Syntax :
- Case1: Navigator.pushReplacement(context, MaterialPageRoute(builder: (context)
=> Your_New_Screen(),));
- Case2: Navigator.push(context,MaterialPageRoute(builder: (context)
=> Your_New_Screen()));
Navigation cont:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Second Route'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);},
child: const Text('Go back!'), ), ),); }}
Navigation and routing:
• Navigation
• Drawer
UserAccountsDrawerHeader
return Scaffold(appBar: AppBar(backgroundColor: Colors.deepPurpleAccent,
title: Text(
"Drawer Interactive Example",
style: TextStyle(color: Colors.white),), ),drawer: Drawer(
child: ListView(
children: <Widget>[
Container(child: UserAccountsDrawerHeader(
currentAccountPicture: CircleAvatar(backgroundImage: NetworkImage(
"https://images.unsplash.com/photo-1545167622-3a6ac756afa4?ixlib=rb-1.2.1
&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60"),),
accountName: Text(
"John Paul",
style: Theme.of(context).textTheme.headline6,),
accountEmail: Text(
"[email protected]",
style: Theme.of(context).textTheme.bodyText1,), ),),
THANK YOU!