<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Nitish Kumar Singh</title>
    <description>The latest articles on Forem by Nitish Kumar Singh (@nitishk72).</description>
    <link>https://forem.com/nitishk72</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F95416%2Fc9bd773f-12a1-4a65-a683-14131ecae63c.png</url>
      <title>Forem: Nitish Kumar Singh</title>
      <link>https://forem.com/nitishk72</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nitishk72"/>
    <language>en</language>
    <item>
      <title>Wallet Security </title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Wed, 26 Aug 2020 09:24:23 +0000</pubDate>
      <link>https://forem.com/nitishk72/wallet-security-1ked</link>
      <guid>https://forem.com/nitishk72/wallet-security-1ked</guid>
      <description>&lt;p&gt;How to detect if someone comes to database and updates their wallet balance?&lt;/p&gt;

</description>
      <category>security</category>
      <category>database</category>
    </item>
    <item>
      <title>Database realated help 😓</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 24 Aug 2020 13:28:17 +0000</pubDate>
      <link>https://forem.com/nitishk72/database-realated-help-16fl</link>
      <guid>https://forem.com/nitishk72/database-realated-help-16fl</guid>
      <description>&lt;p&gt;I am making a multi-restaurant appliances and everything is done but I think it'll not might not scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I have GEO Location (Latitude and Longitude) of user and Restuarant. I am listing all restaurants within 3 Kilometres. I have tested on small scale and it worked but I am worried, what would happen when there will be 100,000 Restuarant. &lt;/p&gt;

&lt;p&gt;If User ask for nearby Restaurants then I will filter from 100,000 Restuarant. To filter I'll calculate distance between user GEO Location to all 100,000 restuarant. &lt;/p&gt;

&lt;p&gt;I don't know if I'm thinking right or wrong? What would be the possibile solution?&lt;/p&gt;

</description>
      <category>database</category>
      <category>postgres</category>
      <category>help</category>
    </item>
    <item>
      <title>Upgrading VS Code Workspace</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 11 Nov 2019 12:06:13 +0000</pubDate>
      <link>https://forem.com/nitishk72/upgrading-vs-code-workspace-1cfe</link>
      <guid>https://forem.com/nitishk72/upgrading-vs-code-workspace-1cfe</guid>
      <description>&lt;p&gt;There are some setting in VS Code which can help you in improving your work-space. I am not going to show you any extensions or install any. I will use internal settings of VS Code which will improve our work-space.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mTYpi3gfIeE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1.breadcrumbs : It is mainly used in website and it really handy there. breadcrumbs is useless in Editor, at least I had never use it. I haven't seen anyone using it.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qJ9IrE6j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cwz8x577t45b3016jzfg.PNG" alt="Alt Text"&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Breadcrumbs are mainly used in Website and here is a snap of breadcrumbs from bootstrap&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--addJfrP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/13vi1ed22sl2rvzh4gi6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--addJfrP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/13vi1ed22sl2rvzh4gi6.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So Disable the breadcrumbs from the settings&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt; 2.minimap: Minimap is not very common, I haven't seen it in lots of editor. Minimap is available in few editors. I don't understand the exact use case of minimap. using minimap I can scroll up and down but I can do that using Scroll bar also. So, why minimap ? I seen lots of developer coding in live conferences and they also don't use it. Although most of the people are not using it they why they don't disable it. So, the we can get some more area in editor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QIaOYtf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oba5eto96amsj2zonwxe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QIaOYtf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oba5eto96amsj2zonwxe.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So, Disable the minimap from the settings&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt; 3.Side Bar : Side is important, I use it and everyone of use it. So, I am not going to tell you to disable. Side Bar is a awesome things but the location/position of sidebar is wrong. It should be in Right but it's in left.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why it should be left ?&lt;/p&gt;

&lt;p&gt;Whenever we open and close the sidebar, the editor area move little right. So, we need to move our eyes to little right for reading the code. Opening and closing of side bar are done lots of time while coding. If you open the side bar and don'e close it then you can keep it in left but if you close the sidebar to get extra space. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Then you should change the position of the sidebar to right&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt; 4.Open Editors: In VS Code we see the opened file in the Side Bar. We don't usually use the open editors to move from one file to other. Basically there are 3 ways to move to any file.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;From the project hierarchy&lt;/li&gt;
&lt;li&gt;Open Editors&lt;/li&gt;
&lt;li&gt;Tabs
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RezU8Ww8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ph2beuagekhsb4op7vlv.PNG" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We usually use the tabs/project hierarchy. So open editors is useless there for most of us. There is a default limit of 3/5/9 file to be shown in the open editors, it means if you have more than 9 file open then you can switch between recent 3/5/9 files only from the open editors. The file limit can be anything but there is a limit and you can't see more than that.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So, get rid of the open editors and get more area in the side bar&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;5.Status Bar : Bottom status bar is cool and I had seen lots of developer uses it for opening the Terminal. Most of the developer uses the status bar and that is very useful for opening the terminal. VS Code is pro editor and there are lots of shortcut and you can bind some more shortcut with some other features. If you get &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s----JsHdKi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o5z87a9f47qkx9a65me1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s----JsHdKi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/o5z87a9f47qkx9a65me1.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you really use the status bar for 1-2 purpose then probably  you should hide it and get some more extra space.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you know any other settings to make work-space clean and great then please comment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is my opinion based on my some years of experience and these reason might not be the sufficient for you. This means, On some point you may agree and and some you don't.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>vs</category>
      <category>vscode</category>
      <category>code</category>
    </item>
    <item>
      <title>Installing Android 4.0 Preview</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Fri, 25 Oct 2019 15:21:35 +0000</pubDate>
      <link>https://forem.com/nitishk72/installing-android-4-0-preview-3gj4</link>
      <guid>https://forem.com/nitishk72/installing-android-4-0-preview-3gj4</guid>
      <description>&lt;p&gt;You can install Android Studio 4.0 Preview which is available in canary and dev channel. There are lots of new things in new Android 4.0 which make me excites to install that.&lt;/p&gt;

&lt;p&gt;Android Studio 4.0 is in Preview version which means this is not for everyone. Preview are not stable release and it’s not available of stable channel. This is for those, who are interested in try and test new features. Preview are&lt;/p&gt;

&lt;p&gt;There are four different channel of android studio release.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Canary&lt;/li&gt;
&lt;li&gt;Dev&lt;/li&gt;
&lt;li&gt;Beta&lt;/li&gt;
&lt;li&gt;Stable&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;You should not expect any bug-free experience from any channel except stable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Android Studio take care of these things, if you will move to other channel that will make two android studio available in you Computer. You can use any Android Studio anytime. You need not to uninstall one and install other.&lt;/p&gt;

&lt;p&gt;If you want early access to the next version of Android Studio, you don’t have to replace your existing stable version. You can install the Android Studio preview side by side with the stable version and work on the same app projects in both.&lt;/p&gt;

&lt;h3&gt;
  
  
  APPLE USER
&lt;/h3&gt;

&lt;p&gt;If you have mac here is a video showing, how to install preview version side by side.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xXCWcZS1lug"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  WINDOWS USER
&lt;/h3&gt;

&lt;p&gt;If you are windows user then I will be uploading video about that soon. Here are the steps which you need to follow.&lt;/p&gt;

&lt;p&gt;1 . Download the Android Studio Preview from this link &lt;a href="https://developer.android.com/studio/preview/" rel="noopener noreferrer"&gt;https://developer.android.com/studio/preview/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extract the zip&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F949%2F1%2AjNlDkQZ0n3fk2aixM1yGpA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F949%2F1%2AjNlDkQZ0n3fk2aixM1yGpA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change the directory name to &lt;strong&gt;Android Studio Preview&lt;/strong&gt; from
&lt;strong&gt;android-studio&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F945%2F1%2A5RnxCZ1XG8UiUhdEm9ybsw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F945%2F1%2A5RnxCZ1XG8UiUhdEm9ybsw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the Android Studio Preview Directory and go to bin folder. There you will find &lt;strong&gt;studio.exe&lt;/strong&gt; and &lt;strong&gt;studio.64.exe.&lt;/strong&gt; Depends upon system architecture(32bit or 64bit) open the files.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1020%2F1%2AyT823hK81sEYPI-FzZANqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1020%2F1%2AyT823hK81sEYPI-FzZANqg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You can’t open this from windows start search. You can pin this to start or taskbar, which will make you will easier for opening this again and again. You can make shortcut to the desktop also.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F968%2F1%2Ao5tcX_w3L1J4NhWE71jvVg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F968%2F1%2Ao5tcX_w3L1J4NhWE71jvVg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  LINUX USER
&lt;/h3&gt;

&lt;p&gt;I don’t have anything for you&lt;br&gt;&lt;br&gt;
Sorry&lt;/p&gt;

</description>
      <category>androidstudio4</category>
      <category>android</category>
      <category>androidstudio</category>
    </item>
    <item>
      <title>Codepen of Flutter</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Sun, 13 Oct 2019 15:27:35 +0000</pubDate>
      <link>https://forem.com/nitishk72/codepen-of-flutter-2ea7</link>
      <guid>https://forem.com/nitishk72/codepen-of-flutter-2ea7</guid>
      <description>&lt;p&gt;Ruining Flutter Code in the Browser&lt;/p&gt;

&lt;p&gt;Now you can easily run the Flutter Code in Browser&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/_Ycd9Go-JSU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>flutter</category>
    </item>
    <item>
      <title>Roadmap for Frontend Developer</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Tue, 10 Sep 2019 20:44:43 +0000</pubDate>
      <link>https://forem.com/nitishk72/roadmap-for-frontend-developer-4m1l</link>
      <guid>https://forem.com/nitishk72/roadmap-for-frontend-developer-4m1l</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uj9L8GOpttk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;HTML + CSS + JS = Fronted Developer but not &lt;strong&gt;modern Fronted Developer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Current Market is looking for a modern front-end developer. So, you need to learn about modern tools. There is a various modern tool and it’s difficult to choose the right tool and order of learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I will help you in knowing the right tool and in the right order.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Every big thing started with a small step and to become master of frontend development you need to start with the basics.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Basics&lt;/li&gt;
&lt;li&gt;CSS Framework&lt;/li&gt;
&lt;li&gt;Package Manager&lt;/li&gt;
&lt;li&gt;CSS Preprocessor&lt;/li&gt;
&lt;li&gt;Build Tool&lt;/li&gt;
&lt;li&gt;Front-end Framework&lt;/li&gt;
&lt;li&gt;Testing&lt;/li&gt;
&lt;li&gt;PWA&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;CSR&lt;/li&gt;
&lt;li&gt;SSR&lt;/li&gt;
&lt;li&gt;Static Site Generator&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These are the things which is very much important for front-end master. I’ll discuss each of this one by one.&lt;/p&gt;

&lt;h4&gt;
  
  
  Basics :
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;👉 HTML:&lt;/strong&gt; Never underestimate the HTML. There are lots of things in HTML which are not being used by people but if you once you know this is also available then you will be surprised. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 CSS:&lt;/strong&gt; It’s tricky and interesting because it styles the page and how it works is a little surprising sometimes. You make your page beautiful with it and you define every property by yourself. It’s like building your own home. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👉 JS:&lt;/strong&gt; JS is the only things which bring logic and programming to the life of frontend developer. It is very much flexible and surprising. It makes own website functional like we see slides we get from verified before sending to the server. Dynamically sending the request to the serve.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;HTML is just mark-up language and it will never give you an error. CSS will also never complain you about the wrong code, but JS will do that.&lt;/em&gt; Once you learn the basics you are ready to move to the next section.&lt;/p&gt;

&lt;h4&gt;
  
  
  CSS Framework
&lt;/h4&gt;

&lt;p&gt;It’s is very important to learn CSS framework because it will make your life easier. You need not do every styling by yourself. You can use the standard predefined style from the framework. If you have a good grasp on CSS, then you can easily override the CSS property and customize the style of the page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Bulma, Bootstrap, Materialize, Semantic UI and Foundation&lt;/strong&gt;. There are the top 5 CSS framework and you must learn at least one and that is Bootstrap.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you ask me to recommend you then I’ll suggest you two framework.&lt;/p&gt;

&lt;p&gt;👉 Bootstrap { Every Developer must know}&lt;/p&gt;

&lt;p&gt;👉 Materialize { Any Material Design Framework }&lt;/p&gt;

&lt;h4&gt;
  
  
  Package Manager
&lt;/h4&gt;

&lt;p&gt;A package manager is a programming language’s tool that automates the process of installing, upgrading, configuring. It also creates project environments and easily imports external dependencies.&lt;/p&gt;

&lt;p&gt;After learning CSS Framework, you might think of learning JS Framework but when you will start learning that ultimately you will come to package manager.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;NPM is node official package manger.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some people don’t use npm then what they use they use &lt;strong&gt;Yarn&lt;/strong&gt; (unofficial package manager)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Yarn is a common project developed by such companies as Facebook, Exponent, Google, and Tilde.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So might think that I told you different thing what you should follow. You can live life with npm there is nothing bad with it but yarn is enhanced version of npm.&lt;/p&gt;

&lt;p&gt;Go with npm after some year/month you will know what is advantages of yarn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌&lt;/strong&gt; Don’t directly jump to yarn because master must know about npm also.&lt;/p&gt;

&lt;h4&gt;
  
  
  CSS pre-processor
&lt;/h4&gt;

&lt;p&gt;A &lt;strong&gt;CSS preprocessor&lt;/strong&gt; is a program that lets you generate &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/CSS"&gt;CSS&lt;/a&gt; from the preprocessor’s own unique syntax. There are many CSS pre-processors to choose from, however, most CSS pre-processors will add some features that don’t exist in pure CSS, such as mixin, nesting selector, inheritance selector, and so on.&lt;/p&gt;

&lt;p&gt;These features make the CSS structure more readable and easier to maintain.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;LESS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SASS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;STYLUS&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;POSTCSS&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This increased productivity and everyone wants things very fast, as fast as it can’t be.&lt;/p&gt;

&lt;h4&gt;
  
  
  Build Tool
&lt;/h4&gt;

&lt;p&gt;👉 Task Runner: Task runner for automating all of those boring repeated processes i.e Grunt.&lt;/p&gt;

&lt;p&gt;👉Modular builder: bundling many web packages and different dependencies, including CSS files and images, then creates modules i.e. webpack.&lt;/p&gt;

&lt;p&gt;👉Linter: Code linting is an important thing to have incorporated in your project because it is a way to increase the code quality&lt;/p&gt;

&lt;p&gt;👉 Formatter: code formatter modifies or fixes your source code, according to the defined configuration previously set up.&lt;/p&gt;

&lt;h4&gt;
  
  
  Front-end Framework
&lt;/h4&gt;

&lt;p&gt;👉 Angular It was built by Google and it the best for enterprise application.&lt;/p&gt;

&lt;p&gt;👉 React It was built by Facebook and this is widely used among all the framework.&lt;/p&gt;

&lt;p&gt;👉 Vue It is growing exponentially, and it has so much potential that it might someday become number.&lt;/p&gt;

&lt;h4&gt;
  
  
  Testing
&lt;/h4&gt;

&lt;p&gt;In the test, we test our UI is fine or not because our code is going to run on different devices with different configuration It impossible to test everywhere and every page manually every time. So we write a test to automate these things. There are 3 types of test&lt;/p&gt;

&lt;p&gt;👉Unit testing: Unit testing is a type of testing to check if the small piece of code is doing what it is supposed to do. Unit testing checks a single component of an application.&lt;/p&gt;

&lt;p&gt;👉INTEGRATION TESTING: Integration testing is a type of testing to check if different pieces of the modules are working together. The behavior of integration modules is considered in Integration testing.&lt;/p&gt;

&lt;p&gt;👉FUNCTIONAL TESTING is a type of software testing whereby the system is tested against the functional requirements/specifications.&lt;/p&gt;

&lt;h4&gt;
  
  
  PWA
&lt;/h4&gt;

&lt;p&gt;Let’s take the example of Whatsapp on your phone. When there is no network, you can still open the app, check past messages and even reply to someone. When the phone gets the internet connection, the messages are being automatically sent in the background.&lt;/p&gt;

&lt;p&gt;👉 SERVICE WORKER&lt;/p&gt;

&lt;p&gt;👉 NOTIFICATION&lt;/p&gt;

&lt;p&gt;👉 LOCATION&lt;/p&gt;

&lt;p&gt;👉 DEVICE ORIENTATION&lt;/p&gt;

&lt;p&gt;👉 STORAGE&lt;/p&gt;

&lt;h4&gt;
  
  
  Performance
&lt;/h4&gt;

&lt;p&gt;Once you get a grasp on the things which I told you about. You need to improve the website in terms of performance. There is a various tool for testing your application performance.&lt;/p&gt;

&lt;p&gt;👉 LIGHTHOUSE&lt;/p&gt;

&lt;p&gt;👉 DEVTOOL&lt;/p&gt;

&lt;p&gt;👉 SPEED TEST&lt;/p&gt;

&lt;p&gt;These are the tools which you will help you and based on the result of these tools, you can improve your website. So, that it will load faster on 2G, 3G or any other network also. You will also get some more way to improve website performance.&lt;/p&gt;

&lt;h4&gt;
  
  
  SSR
&lt;/h4&gt;

&lt;p&gt;If you disable the js and then run any SPA i.e. angular react and vue you will not able to see anything more than an error message. which will say you to enable the javascript.&lt;/p&gt;

&lt;p&gt;👉 React: Next.js&lt;/p&gt;

&lt;p&gt;👉 Angular: Universal&lt;/p&gt;

&lt;p&gt;👉 Vue: Nuxt&lt;/p&gt;

&lt;p&gt;Means spa doesn't work without js. Server-side render website are the website which comes with HTML and CSS. So that HTML and CSS don’t need to be dependent on js. This helps low configuration device to load your website fast. because No JS being interpreted for Rendering UI or DOM manipulation. All the big company who use SPA have a server-side render website also means if you disable the js then also you can see the website.&lt;/p&gt;

&lt;h4&gt;
  
  
  Static Site Generator
&lt;/h4&gt;

&lt;p&gt;Static site generator makes your website static means you can run your website without connecting to the database. It will only HTML, CSS and js which don't contact the database or API for any information.&lt;/p&gt;

&lt;p&gt;👉 React: Gatsby&lt;/p&gt;

&lt;p&gt;👉 Vue: VuePress&lt;/p&gt;

&lt;p&gt;If you are having a blog with some 20 posts then It will fetch all the available post from the database and make it static, like all the posts are being written using in the new file and with HTML Syntax. In this case, I took an example of 20 posts means there will be 20 different pages.&lt;/p&gt;

&lt;p&gt;Thanks for reading I hope you like it that why you are reading this. If you have any suggestion or feedback you can share. I’ll be happy to read it because that is the only thing which can help me in improving myself.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/nitishk72_"&gt;Nitish Kumar Singh🇮🇳 (@nitishk72_) | Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtube.com/c/NitishKumarSingh"&gt;Nitish Kumar Singh&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>react</category>
      <category>javascript</category>
      <category>vue</category>
      <category>angular</category>
    </item>
    <item>
      <title>Flutter: Advance Routing and Navigator Part 1</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 03 Jun 2019 13:52:55 +0000</pubDate>
      <link>https://forem.com/nitishk72/flutter-advance-routing-and-navigator-part-1-547l</link>
      <guid>https://forem.com/nitishk72/flutter-advance-routing-and-navigator-part-1-547l</guid>
      <description>&lt;h3&gt;
  
  
  Flutter: Advance Routing and Navigator (Part 1)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Flutter Advance Routing — Part 1: Talked about only Routing&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blog.usejournal.com/flutter-advance-routing-and-navigator-971c1e97d3d2?source=friends_link&amp;amp;sk=eb6af8894f3efe8c8d0e5ca496a3d5a8"&gt;Flutter Advance Routing — Part 2&lt;/a&gt;: Talked about only Data Sharing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First of all, I am going to start with basic Routing. You can find the basic routing on flutter website also.&lt;/p&gt;

&lt;p&gt;Core concepts and classes for managing multiple screens&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Route&lt;/strong&gt; : A Route is an abstraction for a “screen” or “page” of an app, and a Navigator is a widget that manages routes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Navigator&lt;/strong&gt; : Creates a widget that maintains a stack-based history of child widgets. A Navigator can push and pop routes to help a user move from screen to screen&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Material Page Route&lt;/strong&gt; : A modal route that replaces the entire screen with a &lt;em&gt;platform-adaptive transition&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;What is platform-adaptive Transition ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Transition which you see when routing from one screen to other screens.&lt;br&gt;&lt;br&gt;
&amp;gt; &lt;strong&gt;For Android&lt;/strong&gt; , the entrance transition for the page slides the page upwards and fades it in. The exit transition is the same but in reverse.&lt;br&gt;&lt;br&gt;
&amp;gt; &lt;strong&gt;For iOS&lt;/strong&gt; , the page slides in from the right and exits in reverse. The page also shifts to the left in parallax when another page enters to cover it&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This Transition happens because of &lt;strong&gt;MaterialPageRoute&lt;/strong&gt; only. You can modify this transition also. To modify this transition you need to play with MaterialPageRoute or PageRouteBuilder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/JP54-SQ66UI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Mobile apps typically display full-screen elements called “screens” or “pages”. In Flutter, these elements are called &lt;strong&gt;routes&lt;/strong&gt; and they’re managed by a &lt;strong&gt;Navigator&lt;/strong&gt; widget. The navigator manages a stack of Route objects and provides methods for managing the stack, like &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/push.html"&gt;Navigator.push&lt;/a&gt; and &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/pop.html"&gt;Navigator.pop&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example 1 : Simple Routing&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this example, you can see that I am using method &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/push.html"&gt;Navigator.push&lt;/a&gt; to route to the new screen and &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/pop.html"&gt;Navigator.pop&lt;/a&gt; to go back.&lt;/p&gt;

&lt;p&gt;Navigator maintains the Stack-based history of routes and whatever is at the top of the stack that is our current Page in our App.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/push.html"&gt;&lt;strong&gt;Navigator.push&lt;/strong&gt;&lt;/a&gt; takes two arguments (BuildContext, Route&amp;lt;T&amp;gt;). In the place of Route, we are using &lt;strong&gt;MaterialPageRoute&lt;/strong&gt; which replaces the entire screen with a &lt;strong&gt;platform-adaptive transition&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  To learn about Transition wait for tomorrow
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Route&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MaterialPageRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;route&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecondHome&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Hoem'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pop&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Go Back'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Example 2 : Named Routing&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this example, you can see that I am using method &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/pushNamed.html"&gt;Navigator.pushNamed&lt;/a&gt; to route to the new screen and &lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/pop.html"&gt;Navigator.pop&lt;/a&gt; to go back. Navigator maintain Stack-based history of routes&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.flutter.io/flutter/widgets/Navigator/pushNamed.html"&gt;&lt;strong&gt;Navigator.pushNamed&lt;/strong&gt;&lt;/a&gt; takes two required arguments (BuildContext, String,{Object}) and one optional Argument. In the place of String, we are passing the String which we had predefined in &lt;strong&gt;routes&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
If you have any idea about &lt;a href="https://expressjs.com/"&gt;expressjs&lt;/a&gt; then it looks very much familiar to you.&lt;/p&gt;

&lt;p&gt;As I told you in earlier that MaterialPageRoute is responsible for page Transition and Here in this complete code I haven’t used this MaterialPageRoute then it may be Little difficult for you change the page transition.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I’ll discuss about &lt;strong&gt;onGenerateRoute&lt;/strong&gt; later in this post that help you . You can have custom Transition along with Named Route.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;initialRoute:&lt;/span&gt; &lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;routes:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;WidgetBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;{&lt;/span&gt;
      &lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
      &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
    &lt;span class="o"&gt;},&lt;/span&gt;
  &lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pushNamed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecondHome&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pop&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Go Back'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This was the basic routing and Now I want to tell you something about the above examples.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If in your route &lt;strong&gt;‘&lt;/strong&gt; / &lt;strong&gt;’&lt;/strong&gt; present then it is not mandatory to defined initial route. It will make ‘/’ as your initial route and If you want your initial route different than ‘/’ then you can define.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;This below example will run and will open the HomePage&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;routes:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;WidgetBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;{&lt;/span&gt;
    &lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
    &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="o"&gt;},&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initial route and home are exactly the same you can use anyone at any place. You just need to take care that if you are initial route then you had defined &lt;strong&gt;routes&lt;/strong&gt; or &lt;strong&gt;onGenerateRoute.&lt;/strong&gt; This is not mandatory that there should be ‘/’ in routes.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;This below example will run and will open the second page&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="nl"&gt;routes:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;WidgetBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;{&lt;/span&gt;
    &lt;span class="s"&gt;'/home'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
    &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="o"&gt;},&lt;/span&gt;
&lt;span class="o"&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;If you want that when any route did not match it should show 404 Not Found Link Error Screen then you can use on &lt;strong&gt;UnknownRoute.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="nl"&gt;routes:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;WidgetBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;{&lt;/span&gt;
    &lt;span class="s"&gt;'/home'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
    &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="o"&gt;},&lt;/span&gt;
  &lt;span class="nl"&gt;onUnknownRoute:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RouteSettings&lt;/span&gt; &lt;span class="n"&gt;setting&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="ss"&gt;#&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;ask&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;RouterSettings&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;unknown&lt;/span&gt; &lt;span class="n"&gt;router&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
    &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;unknownRoute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;setting&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;MaterialPageRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;NotFoundPage&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Example 3 : onGenerateRoute&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here you can see I am using &lt;strong&gt;MaterialPageRoute&lt;/strong&gt; and now you can easily modify the Transition Animation. In this case, you need not to routes onGenerateRoute will create the routes for you. Technically routes are present there but that is not initialized by you.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;onGenerateRoute: Creates a route for the given route settings&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
  &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;SecondPage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
  &lt;span class="nl"&gt;onGenerateRoute:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RouteSettings&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;MaterialPageRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;MaterialPageRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SecondPage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;},&lt;/span&gt;
&lt;span class="o"&gt;),&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is a complete custom Transition of Screen. you can copy and paste in your IDE to see the example. Keep one thing in mind that when you change the page Transition it changes for all OS. Default Transition is Platform dependent.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Full Source Code with Demo&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WAJD4PRc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/640/1%2AwE04wcG1kk-_G9_GqpzIcg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WAJD4PRc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/640/1%2AwE04wcG1kk-_G9_GqpzIcg.gif" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt;
      &lt;span class="nl"&gt;onGenerateRoute:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RouteSettings&lt;/span&gt; &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;SlideRightRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;widget:&lt;/span&gt;&lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
          &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;SlideRightRoute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;widget:&lt;/span&gt;&lt;span class="n"&gt;SecondHome&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;},&lt;/span&gt;
    &lt;span class="o"&gt;),&lt;/span&gt;
  &lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pushNamed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'/second'&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecondHome&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Second Home'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;RaisedButton&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;onPressed:&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Navigator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;pop&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
          &lt;span class="o"&gt;},&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Go Back'&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="o"&gt;),&lt;/span&gt;
    &lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SlideRightRoute&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;PageRouteBuilder&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;AppSlideRightRoute&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
      &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;pageBuilder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Animation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Animation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;secondaryAnimation&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;},&lt;/span&gt;
    &lt;span class="nl"&gt;transitionsBuilder:&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Animation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Animation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;secondaryAnimation&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;SlideTransition&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;position:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Tween&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Offset&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;begin:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;Offset&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
          &lt;span class="nl"&gt;end:&lt;/span&gt; &lt;span class="n"&gt;Offset&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;zero&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;animate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;child&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
      &lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;},&lt;/span&gt;
  &lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can follow me get the get Notified about my activities.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/nitishk72/"&gt;nitishk72 - Overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/nitishk72_"&gt;Nitish Kumar Singh🇮🇳 (@nitishk72_) | Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/in/nitishk72/"&gt;Nitish Kumar Singh - Developer - GDG Jalandhar | LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;I think I need to write part-2 of this post because there are a lot more to cover.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you enjoyed or learned let me know on &lt;a href="https://twitter.com/nitishk72_"&gt;Twitter&lt;/a&gt; of anywhere&lt;/p&gt;




</description>
      <category>routing</category>
      <category>transitions</category>
      <category>flutter</category>
    </item>
    <item>
      <title>Understanding Streams in Flutter (Dart)</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 06 May 2019 02:06:05 +0000</pubDate>
      <link>https://forem.com/nitishk72/understanding-streams-in-flutter-dart-2pb8</link>
      <guid>https://forem.com/nitishk72/understanding-streams-in-flutter-dart-2pb8</guid>
      <description>&lt;h1&gt;
  
  
  Understanding Streams in Flutter (Dart)
&lt;/h1&gt;

&lt;p&gt;A stream is one of the challenging topics for the beginner. It took lots of efforts to understand. In order to understand the Streams, you will need to go through the various Examples and then you will get what Exactly Streams is.&lt;/p&gt;

&lt;p&gt;At the end of the post, I will write one Flutter application which will be based on the same example which I had discussed in Dart.&lt;/p&gt;

&lt;p&gt;I am also going to put my understanding of Streams into the words and Examples.&lt;/p&gt;

&lt;p&gt;Streams are a concept Dart. So, I will start streams in Dart and end with applying those concepts in Flutter.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Asynchronous programming in Dart is characterized by the &lt;a href="https://api.dartlang.org/stable/dart-async/Future-class.html" rel="noopener noreferrer"&gt;Future&lt;/a&gt; and &lt;a href="https://api.dartlang.org/stable/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream&lt;/a&gt; classes.
&lt;/h1&gt;

&lt;p&gt;What is Future?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;a href="https://api.dartlang.org/stable/2.2.0/dart-async/Future-class.html" rel="noopener noreferrer"&gt;Future&lt;/a&gt; is used to represent a potential value, or error, that will be available at some time in the future.
&amp;gt; # A simple Example of Future with potential value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // asynchronous data 
    main() async {
      String x = await HelloAsync();
      print(x);
    }

    Future&amp;lt;String&amp;gt; HelloAsync() async{
       await Future.delayed(Duration(seconds:5));
       return 'Message from Future.';
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Why are Streams?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Streams provide an asynchronous sequence of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How stream and Future are similar?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Both works asynchronously&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both have some potential value&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How stream and Future are different?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A stream is a combination of Futures&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Future has only one response but Stream could have any number of Response.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you had ever sent any request to any API in your flutter application then probably you know about async ( Future ).&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  There are two kinds of streams :
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single Subscription&lt;/strong&gt;: There could be a &lt;em&gt;**maximum of one listener *&lt;/em&gt;*to this stream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Broadcast&lt;/strong&gt;: There could be the &lt;em&gt;infinite number of the listener&lt;/em&gt; to this stream.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All the example which I will discuss in this post will be Single Subscription based. Once you understand the single subscription then you can easily understand the Broadcast.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Let’s understand this with examples
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main purpose of this example is to let you understand how the streams work. These examples will make you familiar with some available methods and property of the Stream.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stream Methods
&lt;/h2&gt;

&lt;p&gt;All the available example can be run on Dartpad. I highly recommend you to run the examples and see the pattern of output and understand them.&lt;br&gt;
&lt;a href="https://dartpad.dartlang.org/" rel="noopener noreferrer"&gt;DartPad&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 1:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream .periodic() → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream &amp;lt; T &amp;gt; &lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 2);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval, callback);

  await for(int i in stream){
    print(i);
  }
}

// This callback modify the given value to even number.
int callbank(int value){
  return ( value + 1 ) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s understand the creation of the stream.&lt;/p&gt;

&lt;p&gt;Stream .periodic: Creates a stream that repeatedly emits events at period intervals.&lt;/p&gt;

&lt;p&gt;This is one of the basic streams which you can create easily to make anyone understand about the stream.&lt;/p&gt;

&lt;p&gt;If callback is omitted the event values will all be null.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This stream gives us data every second because we had specified the interval as 2 second.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The argument to this callback is an integer that starts with 0 and is incremented for every event.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is an infinite stream of data because we had not specified any condition.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 2:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream.take(int count) → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream &amp;lt; T &amp;gt; &lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s create a finite stream&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  // Added this statement
  stream = stream.take(5);

await for(int i in stream){
    print(i);
  }
}

int transform(int x){
  return (x + 1) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This is a finite stream of data because we had not specified the condition. The condition says that emit only specified data events. &lt;br&gt;
This will print 2, 4, 6, 8, 10.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;take&lt;/strong&gt;: take(int count) is based on the number of events&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 3:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream.takeWhile(bool test(T element)) → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream&amp;lt; T &amp;gt; &lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can specify the condition on the returned value also.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  // Added this statement
  stream = stream.takeWhile(condition);
  await for(int i in stream){
      print(i);
   }
}
int transform(int x){
  return (x + 1) * 2;
}  
// Added this function
bool condition(int x){
  return x &amp;lt;= 10;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;takeWhile&lt;/strong&gt;: takeWhile(bool test(T element)) is based on the Event emitted value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 4:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream.skip(int count) → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream &lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can skip some first emitted event.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  stream = stream.take(10);
  stream = stream.skip(2);
  await for(int i in stream){
      print(i);
   }
}
int transform(int x){
  return (x + 1) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;This will skip the first 2 Emitted Event&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 5:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream.skipWhile(bool test(T element)) → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Stream &lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can skip the event based on the event value too.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  stream = stream.take(10);
  stream = stream.skipWhile(condition);
  await for(int i in stream){
      print(i);
   }
}
int transform(int x){
  return (x + 1) * 2;
}
bool condition(int x){
  return x &amp;lt; 5;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the test gets a pass then it will skip those value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the test gets fails it will start emitting the value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the test gets fail it will stop checking the condition.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 6:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream.toList() → Future &amp;lt; List &amp;lt; T &amp;gt; &amp;gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This method collects all the data from the stream and store in the List.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  stream = stream.take(5);
  List&amp;lt;int&amp;gt; data = await stream.toList();
  for(int i in data){
      print(i);
   }
}
int transform(int x){
  return (x + 1) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This is async, means you need to wait for some time to get the task done.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When this stream ends, the returned future is completed with that List.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Example 7:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream. listen() → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/StreamSubscription-class.html" rel="noopener noreferrer"&gt;StreamSubscription &amp;lt; T &amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is one specific method for listening to the stream on data. I like the for loop approach because it is much more friendly.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  stream = stream.take(10);

  stream.listen((x){
    print(x);
  });

}
int transform(int x){
  return (x + 1) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Example 8:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream. forEach() → Future&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is one specific method for listening to the stream on data. I like the for loop approach because it is much more friendly.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval,transform);
  stream = stream.take(10);

  stream.forEach((int x){
    print(x);
  });

}
int transform(int x){
  return (x + 1) * 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Stream Property
&lt;/h2&gt;
&lt;h1&gt;
  
  
  Example 9:
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Stream .length → &lt;a href="https://api.dartlang.org/stable/2.3.0/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;Future &amp;lt; int &amp;gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// asynchronous data 
main() async {
  Duration interval = Duration(seconds: 1);
  Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval);
  stream = stream.take(10);
  print(await stream.length);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;length is the property of the stream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It specifies the number of emitted event.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Waits for all events to be emitted in the stream.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now I will create a simple flutter application which will be based on the above example. I am pretty sure you will understand how the stream works in a flutter application. There are various ways of using the stream in flutter application. I am showing you one of them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbxuuc1pog195i25514p.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbxuuc1pog195i25514p.gif" width="432" height="768"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To build app something like this, every beginner will use build a Stateful Widget and will probably use the setState((){}) again and again to update the UI.&lt;/p&gt;

&lt;p&gt;I am going to build the exact same app which is shown in the image&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stateless Widget&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;without setState((){}) ( You can’t call setState((){}) with Stateless)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I will use Stream&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I will use StreamBuilder&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What is this StreamBuilder?&lt;/p&gt;

&lt;p&gt;StreamBuilder listen to the stream and build itself on every new emitted Event by the &lt;a href="https://docs.flutter.io/flutter/dart-async/Stream-class.html" rel="noopener noreferrer"&gt;stream&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s see then stream Builder Implementation.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;child: StreamBuilder&amp;lt;T&amp;gt;(
  stream: stream, // a Stream&amp;lt;int&amp;gt; or null
  builder: (BuildContext context, AsyncSnapshot&amp;lt;T&amp;gt; snapshot) {
    if (snapshot.hasError) return Text('Error: ${snapshot.error}');

    switch (snapshot.connectionState) {
      case ConnectionState.none:
        return Text('Not connected to the Stream or null');
      case ConnectionState.waiting:
        return Text('awaiting interaction');
      case ConnectionState.active:
        return Text('Stream has started but not finished');
      case ConnectionState.done:
        return Text('Stream has finished');
    }
  },
),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can see the above **Example **and get some idea about the StreamBuilder. Stream Builder needs two things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;stream: A source of asynchronous data events. We know how we can build our own asynchronous data event source (using Stream.periodic()).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;builder: We need to write the logic for UI based on asynchronous interaction (stream emitted event).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Connection State&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ConnectionState.none: The stream is null&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ConnectionState.waiting: awaiting interaction&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ConnectionState.active: The stream had started emitting data but not finished yet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ConnectionState.done: The stream has finished.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Here is the final code.
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: HomePage(),
    title: 'Stream Demo',
  ));
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Stream Demo'),
      ),
      body: Center(
        child: StreamBuilder(
          builder: (BuildContext context, AsyncSnapshot&amp;lt;int&amp;gt; snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              return Text(
                '1 Minute Completed',
                style: TextStyle(
                  fontSize: 30.0,
                ),
              );
            } else if (snapshot.connectionState == ConnectionState.waiting) {
              return Text(
                'Waiting For Stream',
                style: TextStyle(
                  fontSize: 30.0,
                ),
              );
            }
            return Text(
              '00:${snapshot.data.toString().padLeft(2,'0')}',
              style: TextStyle(
                fontSize: 30.0,
              ),
            );
          },
          initialData: 0,
          stream: _stream(),
        ),
      ),
    );
  }

  Stream&amp;lt;int&amp;gt; _stream() {
    Duration interval = Duration(seconds: 1);
    Stream&amp;lt;int&amp;gt; stream = Stream&amp;lt;int&amp;gt;.periodic(interval, transform);
    stream = stream.take(59);
    return stream;
  }

  int transform(int value) {
    return value;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This code is using two main thing&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Stream&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;StreamBuilder&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  If you have any doubts about the stream you can ask. I would love to answer your question.
&lt;/h1&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will upload the code to GitHub soon and update the link here.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>stream</category>
      <category>dart</category>
      <category>bloc</category>
    </item>
    <item>
      <title>GraphQL with Flutter</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 29 Apr 2019 17:31:17 +0000</pubDate>
      <link>https://forem.com/nitishk72/graphql-with-flutter-3mdm</link>
      <guid>https://forem.com/nitishk72/graphql-with-flutter-3mdm</guid>
      <description>&lt;p&gt;GraphQL is a query language in which we send the query to the GraphQL Server. The server executes the query at runtime for fulfilling those queries with your existing data.&lt;/p&gt;

&lt;p&gt;Let’s me make you understand this in more easy words. I suppose that you know SQL (Structured Query Language). If we are having a user table with the information about their name, age, email, phone. Now you want to fetch the name and email of the user then you will write a query for that and you will get that information. (Select name, email form the users).&lt;/p&gt;

&lt;p&gt;You will not get age and phone of the user because you have not asked for that information. These are a thing of the server-side (backend). If you are a frontend developer and you had made 20 pages where you need users information. You will ask the backend developer that I want user information on different pages so I need an API. Backend developer will make API will give you an endpoint.&lt;/p&gt;

&lt;p&gt;&amp;gt; on 6 pages you want user’s name only&lt;br&gt;&lt;br&gt;
&amp;gt; on 10 pages you want user’s email and name&lt;br&gt;&lt;br&gt;
&amp;gt; on 4 pages you want user’s name email and phone.&lt;/p&gt;

&lt;p&gt;So you backend developer may apply two approaches.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;He will make 3 different endpoints with different data.&lt;/li&gt;
&lt;li&gt;He can make a common API with all the information.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What is the problem with these two approaches?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We are having multiple endpoints.
If someday we will ned user’s name and age then we need to make another endpoint.&lt;/li&gt;
&lt;li&gt;We are not having multiple endpoints &lt;strong&gt;but&lt;/strong&gt;
We are over fetching the data, on each page we don’t want the user’s phone still we are getting the data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You might think that there is nothing bad with over fetching because extra data will not be going to kill our bandwidth. You are probably wrong here because you are thinking on a low scale. You have not seen the large API’s.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I know you came here to Read about the Flutter&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;but one last &lt;strong&gt;Demo&lt;/strong&gt; about GraphQL then we will move to Flutter part&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F640%2F1%2AOdnn356RBy_nlu27CptELw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F640%2F1%2AOdnn356RBy_nlu27CptELw.gif"&gt;&lt;/a&gt;Demo from GraphQL official website&lt;/p&gt;

&lt;p&gt;There is various implementation for the GraphQL for different Technologies. First, we need to implement the GraphQL on to our server then we ask for data from that server using GraphQL Query. So in a flutter, we don’t need to implement the GraphQL server. We will use a &lt;a href="https://countries.trevorblades.com/" rel="noopener noreferrer"&gt;readymade GraphQL server&lt;/a&gt;from where we will fetch the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://countries.trevorblades.com/" rel="noopener noreferrer"&gt;GraphQL Playground&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Re7FPa3wzN0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let’s come to Flutter coding part and understand how exactly it works.&lt;/p&gt;

&lt;p&gt;Graphql Flutter is 1.x.x is currently available on the &lt;strong&gt;flutter dev channel.&lt;/strong&gt; If you don’t know what is this dev channel and how to channel to the dev channel then don’t worry I’ll tell you.&lt;/p&gt;

&lt;p&gt;Flutter is having 4 channel where flutter (beta, dev, master stable). by default, we all are on the stable channel and in order to use GraphQL (1.x.x). we need to change the channel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to change the channel?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ flutter channel dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you need to check the channel and this will download some Dart never version on which flutter dev channel is dependent. You just need to check the channel and that file will automatically get downloaded.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ flutter channel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Flutter start’s from here
&lt;/h3&gt;

&lt;p&gt;First, we need to add the dependency for the GraphQL (&lt;a href="https://github.com/zino-app/graphql-flutter#readme" rel="noopener noreferrer"&gt;graphql_flutter&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flutter_graphql_demo&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;A new Flutter application.&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.0.0+1&lt;/span&gt;

&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sdk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;=2.1.0&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;lt;3.0.0"&lt;/span&gt;

&lt;span class="na"&gt;dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;flutter&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;sdk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flutter&lt;/span&gt;
  &lt;span class="na"&gt;cupertino_icons&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^0.1.2&lt;/span&gt;
  &lt;span class="na"&gt;graphql_flutter&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;^1.0.0+4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Let’s start the writing code for the flutter. First, we create a GraphQL Client and that client will talk to the GraphQL server we just to notify the client about the GraphQL Query.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let’s set up the GraphQL Client&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:graphql_flutter/graphql_flutter.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="s"&gt;"GQL App"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;()));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApp&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;HttpLink&lt;/span&gt; &lt;span class="n"&gt;httpLink&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpLink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;uri:&lt;/span&gt; &lt;span class="s"&gt;"https://countries.trevorblades.com/"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;ValueNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;GraphQLClient&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ValueNotifier&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;GraphQLClient&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
      &lt;span class="n"&gt;GraphQLClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;link:&lt;/span&gt; &lt;span class="n"&gt;httpLink&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;Link&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nl"&gt;cache:&lt;/span&gt; &lt;span class="n"&gt;OptimisticCache&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;dataIdFromObject:&lt;/span&gt; &lt;span class="n"&gt;typenameDataIdFromObject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;GraphQLProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;HomePage&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="nl"&gt;client:&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will talk about each of the points which is related to GraphQL in the Flutter.&lt;/p&gt;

&lt;p&gt;To use the client it first needs to be initialized with a link and cache. For this example, we will be using an HttpLink as our link and Optimisticache as our cache.&lt;/p&gt;

&lt;p&gt;In line number 15 you can see the link. Link is used for pointing to the endpoint of GraphQL server with the required header (if any). The header is used to authenticate the client.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.flutter.io/flutter/foundation/ValueNotifier-class.html" rel="noopener noreferrer"&gt;ValueNotifier&lt;/a&gt;notified to their listener whenever there is any value change&lt;/p&gt;

&lt;p&gt;We are wrapping our complete page of the application with GraphQLProvider. So, that we can make a request to the GraphQL server without specifying the endpoint and the header. This means from the inside of our page we just need to tell the query and GraphQL provider will do all the tasks for us. That’s why it is known and Client Libray.&lt;/p&gt;

&lt;p&gt;Here we had separated the GraphQL client in a different stateless client we had not written any UI code here because I want to keep them separate (GraphQL Client and Flutter UI).&lt;/p&gt;

&lt;p&gt;This is the Query which we will send to get GraphQL server and display the list of Countries. You can try this query by copying and pasting it to this &lt;a href="https://countries.trevorblades.com/" rel="noopener noreferrer"&gt;GraphQL Server&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query {
 countries {
 name
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Let’s consume reponse of GraphQL Clinet&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we are going to make the UI for our application&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomePage&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sx"&gt;r""&lt;/span&gt;&lt;span class="s"&gt;"
                      query GetCountries{
                          countries {
                            name
                          }
                      }
                  """&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;appBar:&lt;/span&gt; &lt;span class="n"&gt;AppBar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"GraphlQL Client"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;options:&lt;/span&gt; &lt;span class="n"&gt;QueryOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;document:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="n"&gt;QueryResult&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;VoidCallback&lt;/span&gt; &lt;span class="n"&gt;refetch&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;CircularProgressIndicator&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;child&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No Data Found !"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ListView&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nl"&gt;itemBuilder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ListTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'countries'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
              &lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="nl"&gt;itemCount:&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'countries'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is Code for our UI and Let’s understand the GraphQL part out this code.&lt;/p&gt;

&lt;p&gt;We are using &lt;strong&gt;Query()&lt;/strong&gt; widget which is defined by the plugin. It is not a native widget. The &lt;strong&gt;Query&lt;/strong&gt; has two fields here&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;options: Options ask for the query. What query we want to send to the server and if you want to some variable along with query then we have to pass that from the options.&lt;/li&gt;
&lt;li&gt;builder: builder is the same as other builders in a flutter. Builder changes its state based on the data. (You can compare this builder as FutureBuilder.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First, it will send the query to the server and will go to the loading state. you can see the while loading we are showing the CircularProgressBar(). Once the query the executed and loading state gets changed it will come to the completed state.&lt;/p&gt;

&lt;p&gt;In the completed state either it will have an error or it will have the data. If it is not having data then we are showing a message that is &lt;strong&gt;not data found!.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;result.data = the data which you have seen in the GraphQL Playground.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A9z9_TcJwFPraSKpIpmzrdQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A9z9_TcJwFPraSKpIpmzrdQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we get the data then we are showing the response. The response the same as JSON response you just need to grab the countries out of it and show in your UI. I assume that you know this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nitishk72/flutter_graphql_demo" rel="noopener noreferrer"&gt;nitishk72/flutter_graphql_demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading if you like then do clap. If you have anything to say then do comment don’t be alien.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/nitishk72_" rel="noopener noreferrer"&gt;Nitish Kumar Singh🇮🇳 (@nitishk72_) | Twitter&lt;/a&gt;&lt;/p&gt;




</description>
      <category>graphql</category>
      <category>flutter</category>
    </item>
    <item>
      <title>What will be the Output? | JavaScript</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Tue, 12 Mar 2019 11:00:51 +0000</pubDate>
      <link>https://forem.com/nitishk72/what-will-be-the-output--javascript-5f3</link>
      <guid>https://forem.com/nitishk72/what-will-be-the-output--javascript-5f3</guid>
      <description>&lt;h3&gt;
  
  
  I have a program and that is a little bit insane.
&lt;/h3&gt;

&lt;p&gt;This is the program and I wanted to know how many of you already know this concept.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;boy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Natasha&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;birthday&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;date&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;month&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;April&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                    
            &lt;span class="p"&gt;}&lt;/span&gt;   
        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;girl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;boy&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// copying object&lt;/span&gt;

    &lt;span class="nx"&gt;boy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Nitish&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;  
    &lt;span class="nx"&gt;boy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;boy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;December&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;girl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;These types of question are usually asked in the interview.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Comment you answer&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;For more question like this follow me&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>question</category>
    </item>
    <item>
      <title>Hating jQuery will not make you cool</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Mon, 11 Mar 2019 05:41:41 +0000</pubDate>
      <link>https://forem.com/nitishk72/hating-jquery-will-not-make-you-cool-54j6</link>
      <guid>https://forem.com/nitishk72/hating-jquery-will-not-make-you-cool-54j6</guid>
      <description>&lt;p&gt;Hating jQuery will not make you cool; However, adoring it will also not make you cool.&lt;/p&gt;

&lt;p&gt;But In 2019 adoring jQuery will make you dumb.&lt;/p&gt;

&lt;h2&gt;
  
  
  So,
&lt;/h2&gt;

&lt;p&gt;Leave the jQuery as it is and continue your life without it.&lt;/p&gt;

</description>
      <category>jquery</category>
      <category>javascript</category>
    </item>
    <item>
      <title>var vs dynamic in Dart</title>
      <dc:creator>Nitish Kumar Singh</dc:creator>
      <pubDate>Thu, 21 Feb 2019 22:21:24 +0000</pubDate>
      <link>https://forem.com/nitishk72/var-vs-dynamic-in-dart-29al</link>
      <guid>https://forem.com/nitishk72/var-vs-dynamic-in-dart-29al</guid>
      <description>&lt;h4&gt;
  
  
  In Dart and JavaScript we have var keyword for the variable declaration but both are not same.
&lt;/h4&gt;

&lt;p&gt;There is the dynamic keyword for variable declaration in Dart which is equivalent to JavaScript var keyword.&lt;/p&gt;

&lt;p&gt;Dart var keyword is very much similar to javascript var keyword but not the exact same. Most of Dart developer uses Dart var as JS var which is not correct. Let's understand this by some examples. &lt;/p&gt;

&lt;p&gt;I will give 4 different examples.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 1
&lt;/h1&gt;

&lt;p&gt;In JavaScript and Dart, we can store any kind of data in a variable which has been defined using var keyword.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dart
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Maths pi'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Maths pi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Example 2
&lt;/h1&gt;

&lt;p&gt;In JavaScript and Dart, we can store different kind of data in the same variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dart
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Math pi'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;   &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;

    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;   &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Math pi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;

 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Example 3
&lt;/h1&gt;

&lt;p&gt;Now I am going to mix Example 1 and Example 2&lt;br&gt;
Now I am going to initialize the variable and trying to store different data type in the same variable. This is going to give me some error because this is not valid in Dart but its valid in JavaScript.&lt;/p&gt;

&lt;h6&gt;
  
  
  This is the place where &lt;code&gt;var&lt;/code&gt; behaves differently in Dart
&lt;/h6&gt;

&lt;h3&gt;
  
  
  Dart
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is invalid Example this will work&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Math pi'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;


     &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Compilation failed error because&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;               &lt;span class="c1"&gt;// you are trying to assign double to String variable.&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Math pi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;
 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Example 4
&lt;/h1&gt;

&lt;p&gt;If we had used dynamic instead of var in Dart code we haven't got error because dart dynamic is same as JavaScript var.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dart
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is invalid Example this will not work&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'Math pi'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;
     &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;    &lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// expected 3.14&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  JavaScript
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is valid Example this will work&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Math pi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Maths pi&lt;/span&gt;
 &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;3.14&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3.14&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  This is my first post here. If you like it let me so that I can be motivated to post here
&lt;/h1&gt;

</description>
      <category>dart</category>
      <category>var</category>
      <category>dynamic</category>
    </item>
  </channel>
</rss>
