<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Neeraj on Medium]]></title>
        <description><![CDATA[Stories by Neeraj on Medium]]></description>
        <link>https://medium.com/@neeraj.mobcoder?source=rss-2d4f6df41ab6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IiBFxFo8RCj7iiMC.jpg</url>
            <title>Stories by Neeraj on Medium</title>
            <link>https://medium.com/@neeraj.mobcoder?source=rss-2d4f6df41ab6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:48:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neeraj.mobcoder/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flutter: Fetch data from internet]]></title>
            <link>https://medium.com/flutterfly-tech/flutter-fetch-data-from-internet-f5e32a9a33e5?source=rss-2d4f6df41ab6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e32a9a33e5</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Neeraj]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 16:06:20 GMT</pubDate>
            <atom:updated>2023-09-13T16:06:20.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*7u8FCPkkbYM-abXoVRUoAg.png" /></figure><p>While developing any application at some point in SDLC it becomes a mandatory task to handle data locally or from the internet. JSON is popular for lightweight format and storing and transporting data. We might need to fetch data from JSON and show it on the user interface, to accomplish this in a flutter application, we need to follow the following steps:</p><h3><strong>Add the http package</strong></h3><p>Adding http package is super easy, you just need to <a href="https://pub.dev/packages/http#-installing-tab-">click here</a> and follow instructions from there. So let&#39;s do it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*QROWYrhEWTQOMH5ePHhb5g.png" /></figure><p>As the instruction says, add the latest http dependency version to your pubspec.yaml file under the dependencies section. Remember indentation matters here so be careful. The sample is given below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*WunNNIJVw9Iq7dSlfxIgSQ.png" /></figure><p>If you are using Android Studio (which I will recommend you to use), click packages get to add necessary packages, or manually you can hit the command in terminal i.e “<strong>$</strong> <strong>flutter pub get” </strong>to add packages.</p><p>Now in your project’s main.dart file import <strong>http.dart</strong> as follows</p><pre>import &#39;package:http/http.dart&#39; as http;</pre><h3>Network Request</h3><p>To get data from the internet we need to make a request because the internet is all about making requests and getting a response from the other side. And we will do it here by writing below given lines of code</p><pre>Future&lt;Post&gt; fetchPost() async {<br>  final response =<br>  await http.get(&#39;https://jsonplaceholder.typicode.com/posts/17&#39;);<br><br>  if (response.statusCode == 200) {<br>    // If server returns an OK response, parse the JSON.<br>    print(response.body);<br><br>    return Post.fromJson(json.decode(response.body));<br>  } else {<br>    // If that response was not OK, throw an error.<br>    throw Exception(&#39;Failed to load post&#39;);<br>  }<br>}</pre><p>Here we are requesting the JSON and storing its response into Post class.</p><h3>Create Class</h3><p>Since we are requesting and getting a response so we need something that can hold the data received from the other side, so we will make a class so that we can make dart object of what we have received, here is how we can do it</p><pre>class Post {<br>  final int userId;<br>  final int id;<br>  final String title;<br>  final String body;<br><br>  Post({this.userId, this.id, this.title, this.body});<br><br>  factory Post.fromJson(Map&lt;String, dynamic&gt; json) {<br>    return Post(<br>      userId: json[&#39;userId&#39;],<br>      id: json[&#39;id&#39;],<br>      title: json[&#39;title&#39;],<br>      body: json[&#39;body&#39;],<br>    );<br>  }<br>}</pre><h3>Fetching the Data</h3><p>After making a request and storing it into a class created, the next thing we need to do is to fetch data that we need from there.</p><pre>@override<br>void initState() {<br>  // <em>TODO: implement initState<br>  </em>super.initState();<br><br>}</pre><h3>Display the data</h3><p>Here comes the most awaited part i.e showing data received from the internet. We are fetching everything we got in different variables and can call them wherever they needed.</p><pre>getUserData() async {<br>  Post user = await fetchPost();<br>  setState(() {<br>    user1 = user.userId;<br>    id = user.id;<br>    title = user.title;<br>    body = user.body;<br>  });<br><br>}</pre><p>Here is the complete code on which I have explained everything.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a47c11026cc22beaa4d345d532a66a36/href">https://medium.com/media/a47c11026cc22beaa4d345d532a66a36/href</a></iframe><p><strong>Thanks for reading</strong>. If you found this helpful, please share it with your friends.</p><blockquote><strong>Did I get something wrong? Mention it in the comments. I would love to improve.<br>If you liked what you read, please leave some claps!</strong></blockquote><h3>GoodBye</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*n3SefZh8LqE9RxlqSzlAhQ.gif" /></figure><p><strong>Thanks for reading.</strong> If you found this article to be helpful please share it with your friends.</p><p><strong><em>For more about flutter, follow </em></strong><a href="https://medium.com/@neeraj.mobcoder"><strong><em>me</em></strong></a><strong><em>, so you’ll get notified when I write new posts.</em></strong></p><h3>To know more about me, visit :</h3><p><a href="https://about.me/nmaurya/getstarted">https://about.me/nmaurya</a></p><h3>Follow FlutterFly :</h3><p>LinkedIn : <a href="https://www.linkedin.com/in/flutterfly-5726b6189/">https://www.linkedin.com/in/flutterfly-5726b6189/</a></p><p>LinkedIn Group :<strong> </strong><a href="https://www.linkedin.com/groups/10482289/">https://www.linkedin.com/groups/10482289/</a></p><p>Facebook : <a href="https://www.facebook.com/flutterflytech/">https://www.facebook.com/flutterflytech/</a></p><p>Twitter : <a href="https://twitter.com/flutterflytech">https://twitter.com/flutterflytech</a></p><p>GitHub : <a href="https://github.com/flutterflytech">https://github.com/flutterflytech</a></p><p>Medium : <a href="https://medium.com/flutterfly-tech">https://medium.com/flutterfly-tech</a></p><p>Reddit : <a href="https://www.reddit.com/user/flutterflytech/">https://www.reddit.com/user/flutterflytech/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e32a9a33e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutterfly-tech/flutter-fetch-data-from-internet-f5e32a9a33e5">Flutter: Fetch data from internet</a> was originally published in <a href="https://medium.com/flutterfly-tech">FlutterFly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with SwiftUI: iOS Development]]></title>
            <link>https://medium.com/swiftui-forum/getting-started-with-swiftui-ios-development-fccfc5bc16ac?source=rss-2d4f6df41ab6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fccfc5bc16ac</guid>
            <category><![CDATA[navigationview]]></category>
            <category><![CDATA[image]]></category>
            <category><![CDATA[scrollview]]></category>
            <category><![CDATA[hstack]]></category>
            <category><![CDATA[vstack]]></category>
            <dc:creator><![CDATA[Neeraj]]></dc:creator>
            <pubDate>Mon, 09 Aug 2021 04:06:13 GMT</pubDate>
            <atom:updated>2021-08-09T05:32:30.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mApppI2OTWJAOJIc8IMblQ.png" /></figure><p>SwiftUI helps you build great-looking apps across all Apple platforms with the power of Swift — and as little code as possible. With SwiftUI, you can bring even better experiences to all users, on any Apple device, using just one set of tools and APIs.</p><p>Here is a table of content for this blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*afXjVxNIMCfgNoFSRNhVWA.png" /></figure><h3>Keywords</h3><h4>struct:</h4><p><em>Structures</em> and <em>classes</em> are general-purpose, flexible constructs that become the building blocks of your program’s code. You define properties and methods to add functionality to your structures and classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*hM9rLw02_yfEgHmmD9os4Q.png" /></figure><h4>var:</h4><p>Variables associate a name with a value of a particular type. The value of a <em>variable</em> can be set to a different value in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*qMBthOHUbDkfq7BN7D30QQ.png" /></figure><h4>let:</h4><p>You declare constants with the <em>let</em> keyword like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*Quh5onwH40FuKT8AJJ0ZoA.png" /></figure><h4>State:</h4><p>SwiftUI manages the storage of any property you declare as a state. When the state value changes, the view invalidates its appearance and recomputes the body. Use the state as the single source of truth for a given view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*M3fWLDGVY1mVBYbYJrFHFw.png" /></figure><h4>some:</h4><p>Adding the keyword <em>some</em> in front of a return type indicates that the return type is <em>opaque</em>. For a detailed explanation of some, you can check <a href="https://medium.com/@PhiJay/whats-this-some-in-swiftui-34e2c126d4c4">this</a> medium block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*jEVjG10k5UE6HQc1qtdqhg.png" /></figure><h4>func:</h4><p>In swift <em>func </em>is the keyword used for defining functions. Functions could be without Parameters or with parameters. Here is a code snippet for your reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*d0iusoMIT5UoonTL8JjJQQ.png" /></figure><h3>Classes</h3><h4>View:</h4><p>A type that represents part of your app’s user interface and provides modifiers that you use to configure views. You create custom views by declaring types that conform to the View protocol. Implement the required <a href="https://developer.apple.com/documentation/swiftui/view/body-swift.property">body</a> computed property to provide the content for your custom view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*ljdj1crIF6emfkbEPUVCMQ.png" /></figure><h4>HStack:</h4><p>HStack is nothing but a view that arranges its children in a horizontal line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*00hjOXPO4yHToJXP0XLj0w.png" /></figure><h4>VStack:</h4><p>VStack is a view that arranges its children in a vertical line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*w-F005LUcCv8VjXKUSQ8Iw.png" /></figure><h4>HStack:</h4><p>HStack is a view that overlays its children, aligning them in both axes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*mrLMcFrnU6CSpJt-DwqfRw.png" /></figure><h4>Image:</h4><p>A view that displays an image. Use an <em>image</em> instance when you want to add images to your SwiftUI app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*CB1rW4hjRgqsFXZd5_KOgA.png" /></figure><h4>Text:</h4><p>A view that displays one or more lines of read-only text. A text view draws a string in your app’s user interface using a <a href="https://developer.apple.com/documentation/swiftui/font/body">body</a> the font that’s appropriate for the current platform. You can choose a different standard font, like <a href="https://developer.apple.com/documentation/swiftui/font/title">title</a> or <a href="https://developer.apple.com/documentation/swiftui/font/caption">caption</a>, using the <a href="https://developer.apple.com/documentation/swiftui/view/font(_:)">font(_:)</a> view modifier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*H1sAg7zdwjq8VIE5uEN7nA.png" /></figure><h4>Spacer:</h4><p>A flexible space that expands along the major axis of its containing stack layout, or on both axes if not contained in a stack. A spacer creates an adaptive view with no content that expands as much as it can.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*1FkXPaqy2AnYS4LXC7g_SA.png" /></figure><h4>Group:</h4><p>Use a group to collect multiple views into a single instance, without affecting the layout of those views, like an <a href="https://developer.apple.com/documentation/swiftui/hstack">HStack</a>, <a href="https://developer.apple.com/documentation/swiftui/vstack">VStack</a>, or <a href="https://developer.apple.com/documentation/swiftui/section">Section</a> would. After creating a group, any modifier you apply to the group affects all of that group’s members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*JIRHbzJ1VMLsPJN2rkhF1Q.png" /></figure><h4>TabView:</h4><p>A view that switches between multiple child views using interactive user interface elements. To create a user interface with tabs, place views in a TabView and apply the <a href="https://developer.apple.com/documentation/swiftui/view/tabitem(_:)">tabItem(_:)</a> modifier to the contents of each tab. On iOS, you can also use the View/badge(_:) modifier to assign a badge to each of the tabs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*2bt5JOjJ2IVGyLbLCDE2sQ.png" /></figure><h4>Slider:</h4><p>A slider consists of a “thumb” image that the user moves between two extremes of a linear “track”. The ends of the track represent the minimum and maximum possible values. As the user moves the thumb, the slider updates its bound value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*5qxrfPz_y2ZFESJpNJ_56A.png" /></figure><h4>Map:</h4><p>A view that displays an embedded map interface. A map view displays a region. Use this native SwiftUI view to optionally configure user-allowed interactions, display the user’s location, and track location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*iX50FcMlwVSKTG3gn9oxPA.png" /></figure><h4>GroupBox:</h4><p>Use a group box when you want to visually distinguish a portion of your user interface with an optional title for the boxed content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*Qw6V-ckpNqzdqqq5KX49cw.png" /></figure><h4>Divider:</h4><p>The Divider is nothing but a visual element that can be used to separate other content. You can see its implementation in the above code snippet.</p><h4>Link:</h4><p>Link is a control for navigating to a URL. You create a link by providing a destination URL and a title. The title tells the user the purpose of the link, which can be either a string or a title key that returns a localized string used to construct a label displayed to the user in your app’s UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*y1rcHo8_C8TRvW7uOZEkyg.png" /></figure><h4>Circle:</h4><p>A circle is centered on the frame of the view containing it. The circle’s radius equals half the length of the frame rectangle’s smallest edge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*Xx5OitvILC4wMV9IZcscfw.png" /></figure><h4>ScrollView:</h4><p>The scroll view displays its content within the scrollable content region. As the user performs platform-appropriate scroll gestures, the scroll view adjusts what portion of the underlying content is visible. ScrollView can scroll horizontally, vertically, or both, but does not provide zooming functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*sHWQU2SZ2rtzixQAhqzqOQ.png" /></figure><h4>List:</h4><p>A container that presents rows of data arranged in a single column, optionally providing the ability to select one or more members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*zICe3vk1P139426G0Evduw.png" /></figure><h4>NavigationView:</h4><p>Use a NavigationView to create a navigation-based app in which the user can traverse a collection of views. Users navigate to a destination view by selecting a <a href="https://developer.apple.com/documentation/swiftui/navigationlink">NavigationLink</a> that you provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*8CcYRQQts3tFGPFHltlclA.png" /></figure><p><strong>Thanks for reading</strong>. If you found this helpful, please share it with your friends.</p><p>You can find the full code <a href="https://github.com/neerajmaurya250/download_on_isolate_thread">here</a>.</p><blockquote>Did I get something wrong? Mention it in the comments. I would love to improve.<br>If you liked what you read, please leave some claps!</blockquote><h3>GoodBye</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*n3SefZh8LqE9RxlqSzlAhQ.gif" /></figure><p><strong>Thanks for reading.</strong> If you found this article to be helpful please share it with your friends.</p><p><strong><em>For more about flutter, follow </em></strong><a href="https://medium.com/@neeraj.mobcoder"><strong><em>me</em></strong></a><strong><em>, so you’ll get notified when I write new posts.</em></strong></p><h3>To know more about me, visit :</h3><p><a href="https://about.me/nmaurya/getstarted">https://about.me/nmaurya</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fccfc5bc16ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swiftui-forum/getting-started-with-swiftui-ios-development-fccfc5bc16ac">Getting started with SwiftUI: iOS Development</a> was originally published in <a href="https://medium.com/swiftui-forum">SwiftUI Forum</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter BLoC]]></title>
            <link>https://medium.com/flutterfly-tech/flutter-bloc-b83b17678872?source=rss-2d4f6df41ab6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b83b17678872</guid>
            <category><![CDATA[stream]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[bloc]]></category>
            <dc:creator><![CDATA[Neeraj]]></dc:creator>
            <pubDate>Mon, 27 Jul 2020 04:26:59 GMT</pubDate>
            <atom:updated>2020-07-27T04:26:59.046Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fu0iKBSIQgq0-jZ13vwOtg.jpeg" /></figure><p>If you are looking into this article than you must be a beginner with little experience and knowledge about Flutter and dart. The Topic for this blog is very common when you are developing an application and wanted to manage states of your application. So let’s get started</p><h4>What is BLoC and why use it?</h4><p>BLoC is an abbreviation of the <strong>B</strong>usiness <strong>Lo</strong>gic <strong>C</strong>omponent. It is a state management system in Flutter which was introduced by Google at Google I/O 2018. So here in BLoC, we will be using a few terms, mostly like Stream and Sink. We will talk about these two later but the second question was Why to use BLoC, and the answer is because it can manage the state of the whole application from a central place. And as earlier methods that were used to manage state was not suitable for large applications.</p><h4>What are Sink and Stream?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fCzIdnzuv6l5Xy5CoDWjA.jpeg" /></figure><p><strong>Sink</strong></p><blockquote>By the above-given Image, It is clearly seen that sink is something that is given as Input into mainstream.</blockquote><p><strong>Stream</strong></p><blockquote>The stream is something that provides a way to receive a sequence of events. These events are received by someone who is listening to the stream.</blockquote><p>Work Flow of BLoC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7pryDJF6DhP_c0OmXdB_w.jpeg" /></figure><p>Now we have done enough theory and concepts, let’s move on to the next step which is quite exciting that is coding.</p><h4>Step 1</h4><p>Make a Class with any name you like, in my case, I am keeping it related to the topic “DemoBloc”. In this class make a StreamController of private type and respect to that stream a getter and follow the below-given syntax.</p><blockquote>We are making the StreamController of private type to prevent access from other classes, we will use here Stream getter to access the Stream and only those who are listening to the stream will be able to access all things which are available into the stream. But remember no changes can be made.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7dcd014db62876b6e9c82e03260c11d5/href">https://medium.com/media/7dcd014db62876b6e9c82e03260c11d5/href</a></iframe><h4>Step 2</h4><p>In the next step, you need to “Dispose” the stream you have created because the stream will last until you manually dispose it from the stream. Follow the snippet given below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbd40a34f779b1025a7acdf4f75bb6e0/href">https://medium.com/media/bbd40a34f779b1025a7acdf4f75bb6e0/href</a></iframe><h4>Step 3</h4><p>Now if you have ever used setState to manage the state of your application then you must be aware that we need to perform some sort of tasks to get a response from JSON and to store it, here is the <a href="https://medium.com/flutterfly-tech/flutter-fetch-data-from-internet-f5e32a9a33e5">link</a> if you don’t know.</p><p>In BLoC we do all those things except using setState, So what we need to do next is create a class that contains the data from the network request.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02050d0768d27c01ec11c01411acc796/href">https://medium.com/media/02050d0768d27c01ec11c01411acc796/href</a></iframe><h4>Step 4</h4><p>We need to convert the response received from JSON and wrap it into a class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9875df7d3567403fee7e940fb91e2070/href">https://medium.com/media/9875df7d3567403fee7e940fb91e2070/href</a></iframe><h4>Step 5</h4><p>Here comes the most awaited part of the topic, showing data on the user interface, So let&#39;s do it</p><ol><li>Make a method say, “getData” and object of the class you have made to convert JSON and by calling the class to receive data and store it into a variable, here “data” is the variable.</li><li>Here I am checking that if the list we got from JSON is very long then how many items are to be displayed on the screen.</li><li>Now add this data into the stream by sinking it, so that the listeners can receive data from the stream.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/662e2e64761219929d11988c0f190e70/href">https://medium.com/media/662e2e64761219929d11988c0f190e70/href</a></iframe><h4>Step 6</h4><p>Now come to UI i.e “main.dart” code to integrate things we have done previously.</p><ol><li>So here we need to receive data from the stream, to achieve this we will create a List in which we will store the data received from JSON and an instance of the class where we have made the StreamController.</li><li>Get data from the Stream by calling “getData()” function.</li><li>Dispose the Stream.</li><li>Make a list because we are trying to fetch the list from JSON</li><li>Wrap this list by ListView.builder so that the list can be made</li><li>Wrap this list by StreamBuilder widget and make it listen to the stream, and if it gets data from Stream, then save it into the list.</li></ol><p>Follow the below-given code to perform and understand the implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/499a118cda7e6b2f0ebc83c613532e2d/href">https://medium.com/media/499a118cda7e6b2f0ebc83c613532e2d/href</a></iframe><h3>GoodBye</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*1Ex8VmDj_aiqApeU.gif" /></figure><p><strong>Thanks for reading.</strong> If you found this article to be helpful please share it with your friends and if you found any mistake or error ping me on my LinkedIn.</p><p>Complete source code <a href="https://github.com/neerajmaurya250/flutter_BLoC">link</a>.</p><p><strong><em>For more about flutter, follow </em></strong><a href="https://medium.com/@neeraj.mobcoder"><strong><em>me</em></strong></a><strong><em>, so you’ll get notified when I write new posts.</em></strong></p><h3>To know more about me, visit :</h3><p><a href="https://about.me/nmaurya/getstarted">https://about.me/nmaurya</a></p><h3>Follow FlutterFly :</h3><p>LinkedIn : <a href="https://www.linkedin.com/in/flutterfly-5726b6189/">https://www.linkedin.com/in/flutterfly-5726b6189/</a></p><p>LinkedIn Group :<strong> </strong><a href="https://www.linkedin.com/groups/10482289/">https://www.linkedin.com/groups/10482289/</a></p><p>Facebook : <a href="https://www.facebook.com/flutterflytech/">https://www.facebook.com/flutterflytech/</a></p><p>Twitter : <a href="https://twitter.com/flutterflytech">https://twitter.com/flutterflytech</a></p><p>GitHub : <a href="https://github.com/flutterflytech">https://github.com/flutterflytech</a></p><p>Medium : <a href="https://medium.com/flutterfly-tech">https://medium.com/flutterfly-tech</a></p><p>Reddit : <a href="https://www.reddit.com/user/flutterflytech/">https://www.reddit.com/user/flutterflytech/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b83b17678872" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutterfly-tech/flutter-bloc-b83b17678872">Flutter BLoC</a> was originally published in <a href="https://medium.com/flutterfly-tech">FlutterFly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter: ListView & GridView]]></title>
            <link>https://medium.com/flutterfly-tech/flutter-listview-gridview-ce7177812b1d?source=rss-2d4f6df41ab6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce7177812b1d</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutterfly]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Neeraj]]></dc:creator>
            <pubDate>Fri, 28 Feb 2020 10:34:42 GMT</pubDate>
            <atom:updated>2020-02-28T10:37:52.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*du6fsJVVxSRZhLvXeTKHKA.png" /></figure><p>While working with Flutter I needed to create a list in my user interface and I found some wonderful list widget which I will be demonstrating here in this blog. So let&#39;s get started</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKJpkjHGiI5A%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKJpkjHGiI5A&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKJpkjHGiI5A%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3610842d376dde4639880c17772b9a11/href">https://medium.com/media/3610842d376dde4639880c17772b9a11/href</a></iframe><h3>List</h3><p>The list is basically an arrangement of items in such a way that they look organized and easily accessible. The flutter list is more than just a normal list. Here are some types of lists available in flutter:<br>1. Grid List<br>2. Horizontal List</p><p>Mobile application’s fundamental display pattern is showing data in the form of a list. We can use a standard <strong>ListView</strong> constructor to achieve this goal for a fewer item containing list.<br><strong>ListView </strong>constructor has <strong>ListTile</strong> widget<br><strong>ListTile: </strong>A list tile contains one to three lines of text optionally flanked by icons or other widgets, such as checkboxes. The icons (or other widgets) for the tile are defined with the leading and trailing parameters.<br>Here in LIstTile two very important widgets are <strong>leading</strong> and <strong>trailing<br>leading: </strong>This widget is used to show something like an icon or logo or image in the left most of the list.<br><strong>trailing: </strong>This widget is used to show items like icon, image or logo right most of the list.</p><pre>ListView(<br>  children: &lt;Widget&gt;[<br>    ListTile(<br>      leading: FlutterLogo(),<br>      trailing: Icon(Icons.<em>more_vert</em>),<br>      title: Text(&#39;One-line with leading &amp; trailing widget&#39;),<br>    )<br>  ],<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*mVWsOXE_xwP-zOH9LydAZQ.png" /><figcaption>List Example</figcaption></figure><p><strong>Horizontal &amp; Vertical List</strong></p><p>If you want a list which is scrollable left to right i.e horizontally, you just need to add scrollDirection: Axis.horizontal in your code.<br><strong>scrollDirection: </strong>It can be horizontal as well as vertical according to your need</p><pre>ListView(<br>  scrollDirection: Axis.horizontal,<br>  children: &lt;Widget&gt;[<br>    Container(<br>      width: 100,<br>      color: Colors.<em>grey</em>,<br>    ),<br>    Container(<br>      width: 200,<br>      color: Colors.<em>blueGrey</em>,<br>    ),<br>    Container(<br>      width: 200,<br>      color: Colors.<em>green</em>,<br>    ),<br>    Container(<br>      width: 200,<br>      color: Colors.<em>grey</em>,<br>    )<br>  ],<br>)</pre><p>We can set <strong>scrollDirection</strong> as vertical also to enable vertical scrolling on the list, you just need to put below-given code into your ListView widget</p><pre>scrollDirection: Axis.horizontal</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*B_VZ9UNlT0oLdCQsHc5WZg.gif" /></figure><h3><strong>Grid List</strong></h3><p>An alternative to the normal List is Grid List. If you want to show items in a list as a grid that comes one after another below as well as side by side, GridView is the widget for you. Let&#39;s see how it works<br><strong>GridView: </strong>GridView is a scrollable 2D array of widgets. The most frequently used grid layout is <strong><em>GridView.count</em></strong></p><h4><strong>GridView.count</strong></h4><blockquote>It creates a 2D scrollable widget with the flexible number of tiles in the cross axis.</blockquote><pre>GridView.count(<br>),</pre><h4><strong>crossAxisCount</strong></h4><p>It gives you the flexibility to show the number of grids in the cross axis of your view. The below-given snippet will allow showing 2 grid side by side on the body area.</p><pre>crossAxisCount: 2</pre><h4><strong>List.generate</strong></h4><p>It gives you the power of replication of the same grid to a number of times you want to generate it.</p><p><strong>Example</strong></p><pre>GridView.count(<br>  crossAxisCount: 2 ,<br>  children: List.generate(50,(index){<br>    return Container(<br>      child: Card(<br>        color: Colors.<em>blue</em>,<br>      ),<br>    );<br>  }),<br>)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*1m2NsnVfjkY03T3L1BU8eQ.gif" /></figure><p>In the given example and previously explained points, one can easily relate and understand the purpose of all widgets and implementation.</p><p><strong>Sample Code and Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ZSEqpZ366TPGOqF7UsPvPQ.gif" /></figure><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() =&gt; runApp(MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br><br>    return MaterialApp(<br>      home: Scaffold(<br>        body: SafeArea(<br>          child: SingleChildScrollView(<br>            child: Container(<br>              child: Column(<br>                children: &lt;Widget&gt;[<br>                  Container(<br>                    height: 200,<br>                    child: ListView(<br>                      scrollDirection: Axis.horizontal,<br>                      children: &lt;Widget&gt;[<br>                        Container(<br>                          width: 200,<br>                          color: Colors.<em>grey</em>,<br>                        ),<br>                        Container(<br>                          width: 200,<br>                          color: Colors.<em>blueGrey</em>,<br>                        ),<br>                        Container(<br>                          width: 200,<br>                          color: Colors.<em>green</em>,<br>                        ),<br>                        Container(<br>                          width: 200,<br>                          color: Colors.<em>grey</em>,<br>                        )<br>                      ],<br>                    ),<br>                  ),<br>                  Container(<br>                    height: 200,<br>                    child: ListView(<br>                      shrinkWrap: true,<br>                      scrollDirection: Axis.vertical,<br>                      children: &lt;Widget&gt;[<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>yellowAccent</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>blue</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>green</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>red</em>,<br>                        ),Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>yellowAccent</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>blue</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>green</em>,<br>                        ),<br>                        Container(<br>                          width: 50,<br>                          height: 100,<br>                          color: Colors.<em>red</em>,<br>                        )<br>                      ],<br>                    ),<br>                  ),<br>                  Container(<br>                    height: 200,<br>                    child: GridView.count(<br>                      scrollDirection: Axis.horizontal,<br>                      crossAxisCount: 2 ,<br>                      children: List.generate(50,(index){<br>                        return Container(<br>                          child: Card(<br>                            color: Colors.<em>amber</em>,<br>                          ),<br>                        );<br><br>                      }),<br>                    ),<br>                  )<br>                ],<br>              ),<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3><strong>GoodBye</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*n3SefZh8LqE9RxlqSzlAhQ.gif" /></figure><p><strong>Thanks for reading.</strong> If you found this article to be helpful please share it with your friends.</p><p><strong><em>For more about flutter, follow </em></strong><a href="https://medium.com/@neeraj.mobcoder"><strong><em>me</em></strong></a><strong><em>, so you’ll get notified when I write new posts.</em></strong></p><h3>To know more about me, visit :</h3><p><a href="https://about.me/nmaurya/getstarted">https://about.me/nmaurya</a></p><h3>Follow FlutterFly :</h3><p>LinkedIn : <a href="https://www.linkedin.com/in/flutterfly-5726b6189/">https://www.linkedin.com/in/flutterfly-5726b6189/</a></p><p>LinkedIn Group :<strong> </strong><a href="https://www.linkedin.com/groups/10482289/">https://www.linkedin.com/groups/10482289/</a></p><p>Facebook : <a href="https://www.facebook.com/flutterflytech/">https://www.facebook.com/flutterflytech/</a></p><p>Twitter : <a href="https://twitter.com/flutterflytech">https://twitter.com/flutterflytech</a></p><p>GitHub : <a href="https://github.com/flutterflytech">https://github.com/flutterflytech</a></p><p>Medium : <a href="https://medium.com/flutterfly-tech">https://medium.com/flutterfly-tech</a></p><p>Reddit : <a href="https://www.reddit.com/user/flutterflytech/">https://www.reddit.com/user/flutterflytech/</a></p><ul><li><a href="https://medium.com/flutterfly-tech/introduction-to-flutter-getting-started-with-materialapp-scaffold-fccacb9631a9">Introduction to Flutter, getting started with MaterialApp, Scaffold</a></li><li><a href="https://medium.com/flutterfly-tech/scopedmodel-score-counter-app-using-scopedmodel-way-of-state-management-in-the-flutter-adab60c255f3">ScopedModel | Score Counter App using ScopedModel way of state management in the flutter.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce7177812b1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutterfly-tech/flutter-listview-gridview-ce7177812b1d">Flutter: ListView &amp; GridView</a> was originally published in <a href="https://medium.com/flutterfly-tech">FlutterFly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>