<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mavya Soni on Medium]]></title>
        <description><![CDATA[Stories by Mavya Soni on Medium]]></description>
        <link>https://medium.com/@onlysoni3?source=rss-7375ce6c7f29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nlw0oDntcBWiEBH9xxbMKw.jpeg</url>
            <title>Stories by Mavya Soni on Medium</title>
            <link>https://medium.com/@onlysoni3?source=rss-7375ce6c7f29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:16:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@onlysoni3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Navigation and Routing in Flutter]]></title>
            <link>https://medium.com/@onlysoni3/navigation-and-routing-in-flutter-fdcc5875e529?source=rss-7375ce6c7f29------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdcc5875e529</guid>
            <category><![CDATA[flutter-routing]]></category>
            <category><![CDATA[flutter-navigation]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Mavya Soni]]></dc:creator>
            <pubDate>Wed, 08 Apr 2020 13:26:42 GMT</pubDate>
            <atom:updated>2020-04-08T13:26:42.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*DLCgKml36eHhbczLzH8AYQ.png" /></figure><p>Flutter is awesome! When I started learning navigation and routing in the Flutter, I came across some specific scenarios. I discussed the same with my colleagues, but they had no idea. So, I decided to learn navigation deeply and share those scenarios with all of you.</p><p>For the <a href="https://www.solutionanalysts.com/">mobile app development company</a>, Flutter has brought revolutionary changes in developing enterprise-grade apps. Let’s dig deep in Flutter navigation and routing.</p><h3><strong>What is Navigation &amp; Routing in Flutter?</strong></h3><p>In simple terms, we can say that <strong>Navigation &amp; Routing helps us to navigate one screen to another screen and sharing the data between those two screens. </strong>A route is equivalent to an Activity in Android and the same as a route is equivalent to a ViewController in iOS. <strong>In Flutter, a route is just a widget.</strong></p><p>There are two types of routes :</p><ol><li>Unnamed routing</li><li>Named routing</li></ol><h3><strong>Unnamed Routing</strong></h3><p>Unnamed means that it does not have a name. Whenever we need to navigate one screen to another screen at that time we need to use the widget class with <strong>Navigator.push()</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*uWU23S2DJbQIv1mKHlUc1Q.png" /></figure><p>There are two types of PageRoutes :</p><ol><li><strong>MaterialPageRoute: </strong>It is used with MeterialTheme. Which is the Android standard.</li><li><strong>CupertinoPageRoute</strong>: It is used with CupertinoTheme. Which is iOS standard.</li></ol><h4><strong>How to pass the data between two using Unnamed routing?</strong></h4><p>It is very easy, we just need to pass the data in the constructor of widget like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ozD7wpfIx9grNItsGT8lOA.png" /></figure><h3>Named Routing</h3><p>Named means it does have a name. We can define the name of the widget. By using it, we can navigate between two screens. There are many methods. First of all, we need to do some configurations in the MaterialApp widget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*thBXkgqf4UWaUrEy5xvvpA.png" /></figure><p>In Material App we have a routes property where we can define our routes. It means that where we are defining widget class with an alias name. By using <strong>intialRoute</strong> property we can define which screen is going to display while application launches</p><p>By using <strong>Navigator.pushNamed(), </strong>we can go to one screen to another screen. It has three parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*p92CCzNUlpbjm6dMTcp63w.png" /></figure><p>The first parameter represents BuildContext and the second one is the name of the route which we have defined in <strong>routes </strong>property of <strong>MaterialApp.</strong></p><p>The third parameter represents <strong>arguments, </strong>its data type is<strong> Object.</strong> The purpose of the third parameter is passing data between two widgets by using named routes. We can pass any type of data <strong>String, List, Map and Model classes</strong>.</p><h4>How we can receive the data in the second widget?</h4><p>We need to use the <strong>ModalRoute</strong> class for getting data in the second widget[screen].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9tSY5c4N9xYa8t6ILrBMw.png" /></figure><p>Let&#39;s learn how we can get data from the second screen to the first screen. Don’t worry, the same things we need to do in both routing. Let’s deal with it.</p><h3>Return data from the second screen to the first screen</h3><p>It is very easy to handle it in one line. In other technology[Android and iOS] we need to right almost one-page line of code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*7gXdQ5Ui-ZBM-YyP.gif" /></figure><p>But in Flutter, We need to write the below code one line code and our work has done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*K6CgbiRh3-qhaiZ-6qMo4A.png" /></figure><p>There are two ways we can get data from the second screen to the first screen. By using <strong>await</strong>, we can get the data while we come back to the first screen. If we use await, we need to create that <strong>onTap() or onPressed()</strong> event <strong>async</strong>.</p><p>If we don’t want to create an <strong>async</strong> method at that time we can use <strong>then</strong> method like below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*U1hakHk97qeB2v7qqtiWCQ.png" /></figure><p>Thank you for reading. You would find this demo project in <a href="https://github.com/mavyasoni786/flutter-navigator">Github</a>. I will write a blog on advance routing as well till now,</p><h3>😇 Happy Coding!</h3><p><strong>References</strong></p><ol><li><a href="https://flutter.dev/docs/development/ui/navigation">https://flutter.dev/docs/development/ui/navigation</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdcc5875e529" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>