<?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 Annsh Singh on Medium]]></title>
        <description><![CDATA[Stories by Annsh Singh on Medium]]></description>
        <link>https://medium.com/@annsh?source=rss-964a3b5b9eba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7I2djDYg8b0hRYXGuAmkqg.jpeg</url>
            <title>Stories by Annsh Singh on Medium</title>
            <link>https://medium.com/@annsh?source=rss-964a3b5b9eba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:02:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@annsh/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[Protect your data with PGP encryption in Flutter]]></title>
            <link>https://medium.com/flutter-clan/protect-your-data-with-pgp-encryption-in-flutter-525d060a636?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/525d060a636</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[pgp]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Wed, 30 Jun 2021 19:23:29 GMT</pubDate>
            <atom:updated>2021-06-30T19:23:29.772Z</atom:updated>
            <content:encoded><![CDATA[<h3>Protect your data with PGP encryption in Flutter.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yr4NY0O-nU8ow2fj" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>End to end encryption is a great way to ensure a private and secure communication on a platform. You might have heard of this concept while popular apps like WhatsApp and Telegram were integrating this in their services a few years back.</p><p>As a developer of a communication platform, you would want to ensure security on your product as well and for that, we have PGP (Pretty Good Privacy) to the rescue. In fact, PGP is the most widely used email encryption system in the world.</p><p>In simple terms, when PGP is in place, if a sender sends a message then that message can only be decrypted and read by the authorized recipient. This works because only the recipient has the <strong>key</strong> to convert the text back into the readable message on their device.</p><h3>How does it all work?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PseSXWs-rm9mdNCJQH_WEg.png" /><figcaption>Credits: ProtonMail</figcaption></figure><p>Let’s look at the diagram above to understand what actually happens when the data is encrypted and decrypted.</p><ol><li><strong>Encryption: </strong>First, a<strong> </strong><em>random session key</em> is used to encrypt your data. Then, that same session key is encrypted using the <em>receiver’s </em><strong><em>public</em></strong><em> key. </em>Now, the <strong>combination</strong> of the encrypted message and the encrypted session key forms your encrypted message that is sent to the recipient.</li><li><strong>Decryption: </strong>Here, the receiver first <em>decrypts the session key</em> using their <strong><em>private</em></strong><em> key. </em>Next, the decrypted session key would then be used to <em>decrypt</em> the encrypted message, in return of which the user would get a readable message.</li></ol><p>Things to keep in mind:</p><ol><li>Session key used to encrypt should be completely random i.e. not easily guessable as someone who knows the session key can read the message. Also, a session key is unique for every message.</li><li>Public keys are meant to be shared so no harm sharing it over your platform. On the other hand, private keys must never be transmitted. If at all there is a need to do that, one must consider encrypting that as well using a custom encryption technique unique to your platform.</li></ol><p>Now that we are done with the basics, let’s move on to the implementation part.</p><p>For PGP in Flutter, we would be needing the <a href="https://pub.dev/packages/openpgp"><strong>openpgp</strong></a> package.</p><p>We would be following a mixture of <strong>symmetric encryption </strong>and <strong>public key encryption </strong>here.</p><p>We would be encrypting our message using <strong>symmetric</strong> encryption as a message could be huge and symmetric is more efficient that way.</p><p>Let’s have a look at the code now.</p><h4>Encryption:</h4><p>A typical encrypt method would look something like this:</p><pre>static void <em>encrypt</em>(String textMessage, String receiversPublicKey, <br>    Function(String, String, String) returnData) async {</pre><pre><em>///</em><strong><em>Create a session key</em></strong><em> <br>  </em>String sessionKey = getRandomSessionKey();<br><br>  <em>///</em><strong><em>Encrypt data using session key</em></strong><em><br>  </em>String encryptedMessage = await OpenPGP.<em>encryptSymmetric</em>(textMessage, sessionKey);<br><br>  <em>///</em><strong><em>Encrypt session key using receiver&#39;s public key</em></strong><em><br>  </em>String encryptedSessionKey = await OpenPGP.<em>encrypt</em>(sessionKey,    receiversPublicKey);<br><br>  returnData(encryptedMessage, encryptedSessionKey);<br>}</pre><p>Here, we followed the same flow as we had discussed earlier using the diagram above.</p><p><strong>Decryption:</strong></p><pre>static Future&lt;void&gt; <em>decrypt</em>(String encryptedMessage, String encryptedSessionKey, Function(String) returnData) async {</pre><pre>  <em>///</em><strong><em>Decrypt session key with Private key of recipient</em></strong><em><br>  </em>String decryptedSessionKey = await OpenPGP.<em>decrypt</em>(encryptedSessionKey, StreamChatManager.<em>instance</em>.decryptedPrivateKey, &#39;&#39;);<br><br>  <em>///</em><strong><em>Decrypt message with decrypted session key</em></strong><em><br>  </em>String decryptedText = await OpenPGP.<em>decryptSymmetric</em>(encryptedMessage, decryptedSessionKey);<br><br>  returnData(decryptedText);<br>}</pre><p>Here, we would be receiving the encrypted message and encrypted session key. Message would be decrypted symmetrically as it was encrypted symmetrically.</p><p>Here you go.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FWQUfYS1i3R1q2QxEle%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmusicchoice-chris-janson-chrisjanson-reaction-WQUfYS1i3R1q2QxEle&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FWQUfYS1i3R1q2QxEle%2Fgiphy.gif%3Fcid%3D790b7611c329da72d8a52cdebc508b4b42cc8eab58ab104b%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="230" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca088be304dbc91974ed4b55a098a34f/href">https://medium.com/media/ca088be304dbc91974ed4b55a098a34f/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=525d060a636" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-clan/protect-your-data-with-pgp-encryption-in-flutter-525d060a636">Protect your data with PGP encryption in Flutter</a> was originally published in <a href="https://medium.com/flutter-clan">Flutter Clan</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add mentions in your Flutter app (don’t @ me)]]></title>
            <link>https://medium.com/flutter-clan/add-mentions-in-your-flutter-app-dont-me-6b5ea862956?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b5ea862956</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Wed, 30 Jun 2021 19:16:47 GMT</pubDate>
            <atom:updated>2021-06-30T19:16:47.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2t-kmH02QBcdBEA0" /><figcaption>Photo by <a href="https://unsplash.com/@onlineprinters?utm_source=medium&amp;utm_medium=referral">Onlineprinters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We all love to add elements in our app that enhance the overall experience for the end user. One such addition to a typical chat module in your app would be <strong>@mentions</strong>.</p><p>In a group chat, mentions play a huge role. They help the participants refer to other participants in messages, which enables them to collaborate easily in a crowded group chat. If you use any of the apps like WhatsApp, Instagram, Facebook etc, you already know what I am talking about.</p><p>Enabling mentions in your app can be a bit tricky, as you would have to put a module in place that helps recognizing the mentions syntax i.e. anything starting with <strong>“@”</strong>. This would then trigger a series of UI elements which will help you then select one of the group participants and then add them to your text widget with <em>unique styling</em> to distinguish it from the normal text elements in your message.</p><p>Alright, let’s code.</p><h3>Step 1:</h3><p><strong>Import</strong> the following in your project:</p><ul><li><a href="https://pub.dev/packages/markdown">Markdown</a></li><li><a href="https://pub.dev/packages/flutter_markdown">Flutter Markdown</a></li></ul><p>Now that you have done that, we would be using the capabilities of these packages to setup our mentions module.</p><h3>Step 2:</h3><p>We would now be creating two classes, one to help us detect the mentioned text in the message, we would be using a regex for that and another to style the mentioned element.</p><p>In the example shared below, <strong>ColoredBoxInlineSyntax</strong> class is responsible for detection and <strong>ColoredBoxMarkdownElementBuilder </strong>is responsible for formatting the detected text.</p><h3>Example:</h3><p>The main intention of this example is to serve the basic purpose of this article, i.e. letting you know how you can start to integrate the mentions logic in your code. The final implementation might differ depending on your chat service vendor.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FBpGWitbFZflfSUYuZ9%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FBpGWitbFZflfSUYuZ9&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FBpGWitbFZflfSUYuZ9%2Fgiphy.gif%3Fcid%3D790b76110a774757b23b15729e66f3a79ab3dae203bccf05%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="362" frameborder="0" scrolling="no"><a href="https://medium.com/media/719dda83d4199097b7a3ba7bbf666847/href">https://medium.com/media/719dda83d4199097b7a3ba7bbf666847/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a9343eb0f5830a100438c0239a5cb17/href">https://medium.com/media/8a9343eb0f5830a100438c0239a5cb17/href</a></iframe><p>Visual representation of the code above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*5PcbCjrdXV8iysCEIuhoGg.gif" /></figure><p>As you can see from the GIF above, the formatting works as expected.</p><p>We used the power of <strong>Markdown</strong> to help us format our text on the screen.</p><p>Before ending the article, here are the things you can <strong>try for yourself</strong>:</p><ol><li>You can use the same idea to add “#” detection in your application as well.</li><li>Try and show an overlay over text field to select the group members from, just like WhatsApp.</li><li>Try different BG and text color for mentions and hashtags.</li></ol><p>Hope you find this article helpful.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FUjCXeFnYcI2R2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthe-office-fist-bump-UjCXeFnYcI2R2&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FUjCXeFnYcI2R2%2Fgiphy.gif%3Fcid%3D790b76112623cf678aa8cd1b2cd8571c7e3fa0eb364ea17a%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2682ac5478f7a3b0abd50c1ce299bb0/href">https://medium.com/media/e2682ac5478f7a3b0abd50c1ce299bb0/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b5ea862956" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-clan/add-mentions-in-your-flutter-app-dont-me-6b5ea862956">Add mentions in your Flutter app (don’t @ me)</a> was originally published in <a href="https://medium.com/flutter-clan">Flutter Clan</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OverflowBar Widget: A neat way to build responsive Flutter apps.]]></title>
            <link>https://medium.com/flutter-clan/overflowbar-widget-a-neat-way-to-build-responsive-flutter-apps-2f8e76245ee6?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f8e76245ee6</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Wed, 30 Jun 2021 17:57:46 GMT</pubDate>
            <atom:updated>2021-06-30T17:57:46.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L9eeu-qTqnziIDpk" /><figcaption>Photo by <a href="https://unsplash.com/@dancristianp?utm_source=medium&amp;utm_medium=referral">Dan-Cristian Pădureț</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Developers have been building responsive applications on Flutter since the very beginning. You get to cover a wide range of users who might access your application on mobile, tablets, desktops, and even the web. This flexibility allows users to experience your product in different ways, but with this, comes a hurdle for us, the developers. The hurdle I am talking about here is building a flexible responsive design.</p><p>There are different ways to build one. You might have heard of the following ways to achieve responsiveness:</p><ol><li><strong>MediaQuery</strong>: This is the most common approach people follow to put some constraints in place with the help of screen height and width. A typical example being something like this</li></ol><pre>final screenWidth = MediaQuery.<em>of</em>(context).size.width;<br> if (screenWidth &lt; 600.0) {<br>    return _buildMobileLayout();<br> }<br> else if (screenWidth &lt; 1000.0) {<br>    return _buildTabletLayout();<br> }<br> else {<br>    return _buildDesktopLayout();<br> }</pre><p>You might choose to work with orientation as well like</p><pre>Orientation orientation = MediaQuery.of(context).orientation;</pre><p>2. <strong>LayoutBuilder</strong>: The main difference between MediaQuery and LayoutBuilder is that MediaQuery uses the complete context of the screen rather than just the size of your particular widget, whereas LayoutBuilder can determine the maximum width and height of a particular widget.</p><p>Example:</p><pre>LayoutBuilder(<br> builder: (BuildContext context, BoxConstraints constraints) {<br>   if (constraints.maxWidth &gt; 600) {<br>    return _buildWideContainers();<br>   } else {<br>     return _buildNormalContainer();<br>   }<br>  },<br> ),</pre><p>Other widgets would be:</p><p>3. <strong>OrientationBuilder</strong></p><p>4. Various combinations of <strong>Expanded</strong> and <strong>Flexible</strong></p><p>5. <strong>FractionallySizedBox</strong></p><p>6. <strong>AspectRatio</strong></p><p>Now you might have heard or used the widgets mentioned above. They all involve putting in <em>pre-defined constraints in place</em>, one way or another it is on you, the developer, to decide what are the limits you would set to restrict UI for a mobile device, tablets, and desktop. This approach, while it works, might be error-prone and can be a bit frustrating at times.</p><blockquote>We are looking for a Widget that takes this burden off our chest and adjusts itself as per the device.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fqis8fcU0gx75BVVjd7%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fnews-jon-ossoff-help-is-on-the-way-better-days-are-coming-qis8fcU0gx75BVVjd7&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fqis8fcU0gx75BVVjd7%2Fgiphy.gif%3Fcid%3D790b7611f3f1d4dfe625783c780cfe678046d761aba46f45%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="295" frameborder="0" scrolling="no"><a href="https://medium.com/media/5da0307878ec9c6f3c236ac2a54b839a/href">https://medium.com/media/5da0307878ec9c6f3c236ac2a54b839a/href</a></iframe><p>Enters, the <strong>OverflowBar, </strong>a<strong> </strong>widget that lays out its children in a row unless they “overflow” the available horizontal space, in which case it lays them out in a column instead.</p><blockquote>Note: This would work wonderfully if your design and widgets are similar across various screen sizes.</blockquote><p>Let’s pick a typical use case for this.</p><p>Let’s say you are working on a News delivery app where you would like the user to see their feed as a list. The feed item is a combination of an image and a description. Now, in a mobile device, you would like the feed item to be vertical, and on a tablet/web, you might want it to be horizontal i.e. image on the left and its description on the right. You will be able to achieve such flexibility out of the box with <strong>OverflowBar.</strong></p><p>Let’s visualize this using a simple example.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/224487a1374a728a5418ff838b11fb07/href">https://medium.com/media/224487a1374a728a5418ff838b11fb07/href</a></iframe><p>This is how it is rendered on both a mobile phone and on a tablet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tO3kJQ1v09W2FlmoY1i6w.png" /></figure><p>As you can see, the same code is rendered as:</p><ol><li>a <strong>Row</strong>, when there is enough space for the OverflowBar, like in the case of a tablet or a web browser.</li><li>a <strong>Column</strong>, when the size is a bit constrained like in the case of a mobile phone.</li></ol><p>Easy, right?</p><p>Do try it in your applications for a better experience.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F0CVLFj0vE8JpftFJaf%2Fvideo&amp;display_name=GIPHY&amp;url=https%3A%2F%2Fgiphy.com%2Fclips%2Fthefastsaga-fast-and-furious-4-0CVLFj0vE8JpftFJaf&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F0CVLFj0vE8JpftFJaf%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="480" height="270" frameborder="0" scrolling="no"><a href="https://medium.com/media/36c3d9e2345a7cd09357b5d28908d3a3/href">https://medium.com/media/36c3d9e2345a7cd09357b5d28908d3a3/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f8e76245ee6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-clan/overflowbar-widget-a-neat-way-to-build-responsive-flutter-apps-2f8e76245ee6">OverflowBar Widget: A neat way to build responsive Flutter apps.</a> was originally published in <a href="https://medium.com/flutter-clan">Flutter Clan</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Composing” the Flutter counter app with Jetpack Compose: Part 2]]></title>
            <link>https://medium.com/geekculture/composing-the-flutter-counter-app-with-jetpack-compose-part-2-164d4269d7e8?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/164d4269d7e8</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Sat, 22 May 2021 14:56:43 GMT</pubDate>
            <atom:updated>2021-05-26T15:55:54.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59axabEKQo_7JPYpdUWe-w.png" /></figure><p>In <a href="https://annsh.medium.com/composing-the-flutter-counter-app-with-jetpack-compose-part-1-7230d34a1d32"><strong>Part 1</strong></a><strong> </strong>we talked about how one can build a counter app using Jetpack compose. We talked about how you can change layout elements, what is going on when you try to update the UI, and manage state inside an app.</p><p>Let’s go through some of the terms you should have an idea about before we move ahead with the article:</p><ol><li>@Composable annotation</li><li>@Preview annotation</li><li>Recomposition</li><li>mutableStateOf</li><li>remember</li><li>rememberSaveable</li></ol><p>Alright, if you feel that you have some idea about the terms mentioned above, feel free to read ahead. If not, please read <a href="https://annsh.medium.com/composing-the-flutter-counter-app-with-jetpack-compose-part-1-7230d34a1d32"><strong>Part 1</strong></a><strong> </strong>because…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fwogu6dbmagXUI3a3jA%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2F24HoursFOX-fox-foxtv-wogu6dbmagXUI3a3jA&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fwogu6dbmagXUI3a3jA%2Fgiphy.gif%3Fcid%3D790b7611ec81d2ca8712025f5f64f8f42aff9a297fe37b89%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/09ce31984198d2322a21dbd6f6acef15/href">https://medium.com/media/09ce31984198d2322a21dbd6f6acef15/href</a></iframe><h3>State in Jetpack Compose:</h3><p>For a composable to read state changes, Jetpack requires it to be of type <strong>State&lt;T&gt;</strong>. Some common observable types that you might want to use instead mutableStateOf are:</p><ul><li><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#(kotlinx.coroutines.flow.Flow).collectAsState(androidx.compose.runtime.kotlinx.coroutines.flow.Flow.collectAsState.R,%20kotlin.coroutines.CoroutineContext)">Flow</a></li><li><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/rxjava2/package-summary">RxJava2</a></li><li><a href="https://developer.android.com/reference/kotlin/androidx/compose/runtime/livedata/package-summary">LiveData</a></li></ul><p>As you develop reusable composables, you often want to expose both a <strong>stateful</strong> and a <strong>stateless</strong> version of the same composable.</p><blockquote>The stateful version is convenient for callers that don’t care about the state, and the stateless version is necessary for callers that need to control or hoist the state.</blockquote><p>The<strong> Part 1</strong> we had Stateless composables in play. Both CenterText and MyFab are Stateless.</p><p>Now, let’s see how adding a ViewModel in the picture would help us manage State. We will be using ViewModel to expose the state in an observable holder (like LiveData or Flow) and also to handle events that affect that state.</p><p>First, add these dependencies to your build.gradle file:</p><pre>implementation &quot;androidx.compose.runtime:runtime-livedata:$compose_version&quot;</pre><pre>implementation &quot;androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05&quot;</pre><p>This will let you access both <em>observeAsState </em>and <em>viewModel</em>() in your MainActivity.kt file.</p><p>Next, in your project, create a new Kotlin class by the name of <strong>CounterViewModel</strong>. It should look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71853bdb9368957c5cbb8a9ad6b86cde/href">https://medium.com/media/71853bdb9368957c5cbb8a9ad6b86cde/href</a></iframe><p>Next, in your MainAcitivity.kt file, update your MainView composable like this:</p><pre>@Preview(showBackground = true, showSystemUi = false)<br>@Composable<br>fun MainView(counterViewModel: CounterViewModel = <strong><em>viewModel</em></strong>()) {<br>    val count by counterViewModel.counterLiveDate.<strong><em>observeAsState</em></strong>(0)<br>    <em>Scaffold</em>(<br>        topBar = <strong>{<br>            </strong><em>TopAppBar</em>(<br>                title = <strong>{<br>                    </strong><em>Text</em>(text = &quot;CounterApp&quot;)<br>                <strong>}</strong>,<br>            )<br>        <strong>}</strong>,<br>        floatingActionButton = <strong>{<br>            </strong><em>MyFab </em><strong>{<br>                </strong>counterViewModel.increaseCounter()<br>            <strong>}<br>        }</strong>,<br>        content = <strong>{<br>            </strong><em>CenterText</em>(count)<br>        <strong>}</strong>,<br>    )<br>}</pre><p>New imports added to MainActivity should be:</p><pre>import androidx.compose.runtime.livedata.observeAsState<br>import androidx.lifecycle.viewmodel.compose.viewModel</pre><p>Here, we pass the viewmodel to the MainView composable to get access to the LiveData that the UI can read as the State and update itself as and when the value changes.</p><p>Rest everything remains the same as both the other composables were Stateless i.e. the State was managed by the MainView composable.</p><p>Rebuild the app and Voila!, the counter increases when you tap the FAB.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F8UF0EXzsc0Ckg%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ffinally-atlast-itsover-8UF0EXzsc0Ckg&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2F8UF0EXzsc0Ckg%2Fgiphy.gif%3Fcid%3D790b76114090ed7547e7a0d18172a1968f5e42d99df4188d%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="261" frameborder="0" scrolling="no"><a href="https://medium.com/media/de8d374a363f8de3d034086f363df64f/href">https://medium.com/media/de8d374a363f8de3d034086f363df64f/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=164d4269d7e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/composing-the-flutter-counter-app-with-jetpack-compose-part-2-164d4269d7e8">“Composing” the Flutter counter app with Jetpack Compose: Part 2</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Composing” the Flutter counter app with Jetpack Compose: Part 1]]></title>
            <link>https://medium.com/geekculture/composing-the-flutter-counter-app-with-jetpack-compose-part-1-7230d34a1d32?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/7230d34a1d32</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[declarative-programming]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Sun, 02 May 2021 11:14:07 GMT</pubDate>
            <atom:updated>2021-05-26T15:56:42.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4CkTwWfsFsq5ADJHDMXnvA.png" /></figure><p>I experienced the comfort of getting away from designing my layouts using XML when I shifted towards <strong>Flutter</strong>. Having spent almost 3 years working with the Declarative UI, I feel that it is the future. The introduction of Jetpack Compose in the case of Android and SwiftUI in the case of iOS says a lot about that feeling. Recently I got my hands dirty with Jetpack Compose and I must say, it felt amazing. Native development won’t be the same after this.</p><blockquote><strong>Note: </strong>As of writing this article, the compose is at <strong>1.0.0-beta05</strong>. Things might change with further updates. Please check the latest updates <a href="https://developer.android.com/jetpack/androidx/releases/compose"><strong>here</strong></a><strong>.</strong></blockquote><p>After going through the documentation, I found a lot of similarities in the way things are working in compose and Flutter.</p><p>To start, simply go to this <a href="https://developer.android.com/jetpack/compose/documentation"><strong>link</strong></a> and start following the steps. Here, the <strong><em>foundation section</em></strong> is the most important one. It’ll help you start thinking in compose, what to do and not do while working with compose, managing state, and the Lifecycle of a composable.</p><p>It seems like a lot, but it is very important to understand the basics before working on a project.</p><p>💻 As a Flutter developer, after going through the basics, my first instinct was to work on the <strong>Counter app</strong> that is built by default when you create a new Flutter project.</p><p>Let me walk you through all you need to do to create one.</p><blockquote><strong>Note:</strong> I would be pacing through the <strong>basic introduction</strong> of Jetpack Compose during the initial steps here. I would be giving you a path to walk on to understand the basics and jump on to creating your first app in Compose.</blockquote><h3>Step 1:</h3><p>Create a new project that includes support for <strong>Jetpack Compose</strong> by default. To do this, go to this <a href="https://developer.android.com/jetpack/compose/setup#create-new"><strong>link</strong></a> and follow the steps. After you are done with the setup, feel free to go to this <a href="https://developer.android.com/jetpack/compose/tutorial"><strong>link</strong></a><strong> </strong>to get a taste of what you are getting into.</p><h3><strong>Step 2:</strong></h3><p>Here, I am assuming that you are now familiar with what <strong>@Composable</strong> and <strong>@Preview</strong> annotations are and how you can put some basic set of Widgets on a screen and modify their properties.</p><p>Next, you would want to wrap your head around the idea of a declarative UI pattern. For that, go to this <a href="https://developer.android.com/jetpack/compose/mental-model"><strong>link</strong></a><strong>.</strong></p><p>Few key parts that I would want you to focus on in this document would be:</p><ol><li>Understand how compose handles rebuilding the whole UI tree and how to manage it well when you would want to update a certain UI element on the screen (<a href="https://developer.android.com/jetpack/compose/mental-model#recomposition">Recomposition</a>)</li><li>You would also want to focus on the things that one should <strong>NOT do</strong> while working with Compose. Referred to as “<strong>side-effects</strong>” in the doc.</li><li>Next, focus on the part where you get to know how:</li></ol><pre>3.1 Composable functions can <strong>execute in any order</strong> - Don&#39;t let one of your composable depend on another.<br> <br>3.2 Composable functions can <strong>run in parallel</strong> - Optimization and one side-effect you should keep in mind. </pre><pre>3.3 Recomposition <strong>skips</strong> as much as possible - Optimization and oh yeah, they mention the side-effect again. Must be really important to remember that. </pre><pre>3.4 Recomposition is <strong>optimistic</strong> - Compose expects to finish recomposition before the parameters change again.</pre><pre>3.5 Composable functions might <strong>run quite frequently </strong>- Pass the data to Compose using <em>mutableStateOf</em> or <em>LiveData. </em>What&#39;s that? We&#39;ll get to it. </pre><p>Now that you have read the whole document, you are ready to move ahead with a better understanding of Compose.</p><blockquote>Before we move ahead, do you know what the word <strong><em>idempotent </em></strong>stands for? No? Please read the whole document again 🙂</blockquote><h3>Step 3:</h3><p>You are nearly there.</p><p>We are done with the very basics of Jetpack Compose, and now comes one of the most important parts: <a href="https://developer.android.com/jetpack/compose/state"><strong>State</strong></a>.</p><h4>MutableStateOf:</h4><p>Remember we read about <em>mutableStateOf and </em><em>LiveData </em>in 3.5 above? We would get to LiveData and more in <strong>Part 2</strong> but for now, let’s stick to <em>mutableStateOf </em>and see what all it can do to help us maintain state in our app.</p><p>Now we already know that a composition can only be produced by an initial composition and <strong>updated by recomposition</strong>. The only way to modify a composition is through <strong>recomposition</strong>. So what mutableStateOf does is it creates a MutableState, which is an <strong>observable</strong> type in Compose. Any changes to its value will <em>schedule recomposition</em> <strong>of any composable functions that read that value.</strong></p><p>Pretty neat right? But while making changes to a variable, you would want the state to be preserved across recompositions i.e. you would want your state to be remembered right?</p><p>We have just the composable for that called, you guessed it, <strong>remember.</strong></p><h4><strong>Remember composable:</strong></h4><pre>var name by remember { mutableStateOf(&quot;&quot;) }</pre><p>Here, you can use this name variable to update your UI by passing it on to a Composable as a parameter. Although <strong>remember</strong> helps you retain state across recompositions, the state is not retained across configuration changes. For this, you must use <strong>rememberSavable.</strong></p><p>Example:</p><pre>var name by rememberSaveable { mutableStateOf(&quot;&quot;) }</pre><h4><strong>Stateless composable:</strong></h4><p>One more thing to note in the case of State in composable is that one should be working with <strong>Stateless composable</strong> i.e.</p><pre>composable <strong>does not</strong> hold its own state and thus it is not tightly coupled to how its state is stored. This way, composable is easy to reuse and test.</pre><p>To do this, you can use <em>state hoisting. </em>I feel the example <a href="https://developer.android.com/jetpack/compose/state#stateless-composables"><strong>here</strong></a> is more than enough for you to understand the concept.</p><p>Alright, looks like we are all set to work on our beloved Counter app.</p><p>Let’s begin</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FPiQejEf31116URju4V%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmemecandy-PiQejEf31116URju4V&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FPiQejEf31116URju4V%2Fgiphy.gif%3Fcid%3D790b761149efb3a9d17ebe71a2bd50b9bc38dcddeeb551c0%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="261" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a6abf0ae2133ee34c4aa283d919d07d/href">https://medium.com/media/6a6abf0ae2133ee34c4aa283d919d07d/href</a></iframe><p>First, let’s revisit the app we created in <strong>Step 1. </strong>In that update the <strong>MainActivity.kt</strong> file with the following gist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83093f254d7c203b3c34c00b8f40399d/href">https://medium.com/media/83093f254d7c203b3c34c00b8f40399d/href</a></iframe><p>Run the app on your emulator/device and click on the FAB to see the count increasing on the UI.</p><p>Wish to change the theme and match it to the one used in the Flutter counter app? Simple, inside <strong>ui.theme</strong> folder open <strong>Color.kt</strong> file and replace the values as :</p><pre>val <em>Blue200 </em>= <em>Color</em>(0xFF90CAF9)<br>val <em>Blue500 </em>= <em>Color</em>(0xFF2196F3)<br>val <em>Blue700 </em>= <em>Color</em>(0xFF1976D2)</pre><p>and then, open the <strong>Theme.kt </strong>file and update it as:</p><pre>primary = Blue200,<br>primaryVariant = Blue700,</pre><p>Rebuild the app and Voila!, the theme is the same as that of the default Flutter counter app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oz8xsRKgCWlzkqT7y%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ftipsyelves-yeah-boom-3oz8xsRKgCWlzkqT7y&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F3oz8xsRKgCWlzkqT7y%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd4f237d837475f826fc4dddaebe9ffa/href">https://medium.com/media/cd4f237d837475f826fc4dddaebe9ffa/href</a></iframe><p>In <strong>Part 2</strong>, we would modify this app to work with <strong>ViewModel</strong> for State management.</p><p><a href="https://annsh.medium.com/composing-the-flutter-counter-app-with-jetpack-compose-part-2-164d4269d7e8">“Composing” the Flutter counter app with Jetpack Compose: Part 2</a></p><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7230d34a1d32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/composing-the-flutter-counter-app-with-jetpack-compose-part-1-7230d34a1d32">“Composing” the Flutter counter app with Jetpack Compose: Part 1</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Quick Bites Part 2: Nested GestureDetector, to click or not to click?]]></title>
            <link>https://medium.com/flutter-clan/flutter-quick-bites-part-2-nested-gesturedetector-to-click-or-not-to-click-bbf204c5afc1?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbf204c5afc1</guid>
            <category><![CDATA[nested]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[gesturedetector]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Thu, 22 Apr 2021 06:52:55 GMT</pubDate>
            <atom:updated>2021-04-22T06:52:55.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KomcPcHW8gySXhQV" /><figcaption>Photo by <a href="https://unsplash.com/@graysonsmith_photography?utm_source=medium&amp;utm_medium=referral">Grayson Smith</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is <strong>part 2</strong> in the series where I would be sharing tips that will help you ease your Flutter app development process.</p><p>Think about one situation for a minute. What if you wrap a GestureDetector inside a GestureDetector. Which GestureDetector would dominate in case of click events by default? Can you control which one should dominate?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FBmmfETghGOPrW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freaction-BmmfETghGOPrW&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FBmmfETghGOPrW%2Fgiphy.gif%3Fcid%3D790b7611b54c70f8dab2b7e727210392145015a6e08ef644%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="186" frameborder="0" scrolling="no"><a href="https://medium.com/media/57c32bddfac35b7fbd126f921c8f2109/href">https://medium.com/media/57c32bddfac35b7fbd126f921c8f2109/href</a></iframe><p>Tricky isn’t it?</p><p>Well, this article has answers to the above-mentioned questions. Let’s try and see for ourselves what would happen in different situations along with working examples.</p><blockquote>Note: A working <strong>DartPad example link</strong> is at the end of the article.</blockquote><p>GestureDetector has a <strong>behavior</strong> property attached to it. This property can have 3 values:</p><ol><li><em>deferToChild (default value)</em></li><li><em>opaque</em></li><li><em>translucent</em></li></ol><p>This article will focus on just the first two values.</p><h4><strong>Situation 1: </strong>Default Behavior</h4><pre>Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: [<br>            Text(&#39;Click the number below&#39;),<br>            SizedBox(height: 12),<br>            GestureDetector(<br>              <strong>behavior: HitTestBehavior.deferToChild,</strong><br>              onTap: () {<br>                setState(() {<br>                  _counter = _counter + 10;<br>                });<br>              },<br>              child: IgnorePointer(<br>                <strong>ignoring: true/false,</strong><br>                child: GestureDetector(<br>                  onTap: () {<br>                    setState(() {<br>                      _counter = _counter + 20;<br>                    });<br>                  },<br>                  child: Text(<br>                    &#39;$_counter&#39;,<br>                    style: Theme.of(context).textTheme.headline4,<br>                  ),<br>                ),<br>              ),<br>            ),<br>          ],<br>        ),</pre><p>Here we have <strong>two GestureDetector</strong> widgets.</p><blockquote>Let’s refer the one outside <strong>Parent GestureDetector: PGD</strong> and the one inside as <strong>Child GestureDetector: CGD </strong>from hereon.</blockquote><p>The PGD has the <strong>behavior </strong>set to the default value of <em>HitTestBehavior.deferToChild.</em></p><p>The CGD on the other hand is wrapped inside <strong>IgnorePointer</strong>. This is done to explore various situations.</p><p>In the one above, take a moment to analyze what would happen if the:</p><ol><li><strong><em>ignoring </em>property is set to true</strong>.</li></ol><p>Nothing. Yup, if you try and click on the number on the screen, nothing would happen. Why? Because, PGD’s default behavior property (i.e. <em>HitTestBehavior.deferToChild</em>) lets the CGD receive click events and since it is wrapped inside an IgnorePointer widget with its <em>ignoring</em> property set to <strong>true</strong>, <em>it ignores the click events</em>.</p><p>2. <strong><em>ignoring</em> property is set to false</strong>.</p><p>Change the <strong><em>ignoring</em></strong><em> </em>property of the IgnorePointer to <strong>false</strong>, and the CGD would start receiving the click events and the _<em>counter </em>variable value would increase by 20 on each click.</p><h4>Situation 2: Let PGD dominate over CGD</h4><p>Now that we have seen what the default behavior is, let&#39;s explore the one where the PGD receives events instead of CGD.</p><pre>Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: [<br>            Text(&#39;Click the number below&#39;),<br>            SizedBox(height: 12),<br>            GestureDetector(<br>              <strong>behavior: HitTestBehavior.opaque,</strong><br>              onTap: () {<br>                setState(() {<br>                  _counter = _counter + 10;<br>                });<br>              },<br>              child: IgnorePointer(<br>                <strong>ignoring: true,</strong><br>                child: GestureDetector(<br>                  onTap: () {<br>                    setState(() {<br>                      _counter = _counter + 20;<br>                    });<br>                  },<br>                  child: Text(<br>                    &#39;$_counter&#39;,<br>                    style: Theme.of(context).textTheme.headline4,<br>                  ),<br>                ),<br>              ),<br>            ),<br>          ],<br>        ),</pre><p>Here, as you must have observed by now, we have changed the <em>behavior </em>property of the PGD to <strong>HitTestBehavior.opaque </strong>and the CGD is still wrapped inside an <strong>IgnorePointer with ignoring property set to true</strong>.</p><p>Now, if you click on the counter text, its value will increase by 10 on every click.</p><p><strong>Note:</strong> If the <em>ignoring</em> property is set to <strong>false</strong>, the behavior property would not work and the click events would again be received by CGD.</p><h4>Relevant Links :</h4><p><strong>👨🏻‍💻 DartPad</strong>: Run the example on DartPad using this <a href="https://dartpad.dev/1a7937fb0adbcb2da7bda06d8d910de8"><strong>link</strong></a>.</p><p><strong>Bonus 🍪 :</strong></p><p>Here’s a <a href="https://github.com/leoafarias/fvm"><strong>package</strong></a> for you to explore. It allows you to have multiple Flutter versions installed on your machine.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3ohc0UBfKFgX8dXkB2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fgames-olympics-3ohc0UBfKFgX8dXkB2&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2F3ohc0UBfKFgX8dXkB2%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e5f5aa6ab7de0e56aed206621c56671/href">https://medium.com/media/4e5f5aa6ab7de0e56aed206621c56671/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbf204c5afc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-clan/flutter-quick-bites-part-2-nested-gesturedetector-to-click-or-not-to-click-bbf204c5afc1">Flutter Quick Bites Part 2: Nested GestureDetector, to click or not to click?</a> was originally published in <a href="https://medium.com/flutter-clan">Flutter Clan</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Quick Bites Part 1: Spread Operator, Visibility with a twist.]]></title>
            <link>https://medium.com/flutter-clan/flutter-quick-bites-part-1-spread-operator-visibility-with-a-twist-66e9f35f3350?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/66e9f35f3350</guid>
            <category><![CDATA[spread-operator]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[visibility]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Wed, 21 Apr 2021 05:33:26 GMT</pubDate>
            <atom:updated>2021-04-28T07:07:21.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ap6CHNONV4WJJaCJ" /><figcaption>Photo by <a href="https://unsplash.com/@mockaroon?utm_source=medium&amp;utm_medium=referral">Mockaroon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this series, I would be sharing tips that will help you ease your Flutter app development process. We, as developers, are always on the lookout for small enhancements that we can do to either <em>speed up our development</em> process or just <em>enhance the overall look and feel</em> of the code structure. I want this series to be your one-stop guide for that.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F7Sh3Pt6R9ELubdoH3K%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthebachelorette-abc-bachelorette-the-7Sh3Pt6R9ELubdoH3K&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F7Sh3Pt6R9ELubdoH3K%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/35d01b64306ac0c28ef1bc847d12605a/href">https://medium.com/media/35d01b64306ac0c28ef1bc847d12605a/href</a></iframe><p>How nice would it be to control your widget&#39;s visibility on the basis of a bool condition? Oh wait, we have a <strong>Visibility</strong> widget for just that. True, but you might face a situation where the Visibility widget is required for multiple widgets and you end up using it again and again, taking up space in your widget tree. Also, it is best to have fewer widgets in your widget tree as that impacts the performance of your app. To get rid of this problem, we have a neat solution in place.</p><blockquote>Note: A working <strong>DartPad example link</strong> is at the end of the article.</blockquote><h4><strong>Let’s first have a look at the usual way of doing things:</strong></h4><p>The situation is such, that you have to control the visibility of two widgets in a Row on the basis of a condition i.e. <em>hide videocam and share icons</em> whenever <strong>_counter</strong> variable has an Even value.</p><pre><br>            Row(<br>              mainAxisSize: MainAxisSize.max,<br>              mainAxisAlignment: MainAxisAlignment.spaceEvenly,<br>              children: &lt;Widget&gt;[<br>                Container(<br>                  child: Icon(Icons.photo, size: 50),<br>                ),<br>                Container(<br>                  child: Icon(Icons.music_note, size: 50),<br>                ),<br>                <strong>Visibility(<br>                  visible: _counter % 2 == 0,<br>                  child: Container(<br>                    child: Icon(Icons.videocam, size: 50),<br>                  ),<br>                ),</strong><br>                <strong>Visibility(<br>                  visible: _counter % 2 == 0,<br>                  child: Container(<br>                    child: Icon(Icons.share, size: 50),<br>                  ),<br>                ),</strong><br>              ],<br>            ),</pre><p>Here, let’s focus on the part where we check the condition if the value of the <em>_counter</em> variable is even or not. There are <strong>two Visibility</strong> widgets in place, that are <strong>hidden</strong> when the value of <em>_counter</em> variable is Even.</p><p>Does this solve our purpose? Absolutely. But what if there were 10 more widgets for which you needed to control the visibility? You would then be wrapping each widget with Visibility to get this done.</p><h4><strong>There must be a better solution, and there is. 👇🏻</strong></h4><pre>             Row(<br>              mainAxisSize: MainAxisSize.max,<br>              mainAxisAlignment: MainAxisAlignment.spaceEvenly,<br>              children: &lt;Widget&gt;[<br>                Container(<br>                  child: Icon(Icons.photo, size: 50),<br>                ),<br>                Container(<br>                  child: Icon(Icons.music_note, size: 50),<br>                ),</pre><pre>                //Using the spread operator instead of Visibility<br>                <strong>if (_counter % 2 == 0) ...[<br>                  Container(<br>                    child: Icon(Icons.videocam, size: 50),<br>                  ),<br>                  Container(<br>                    child: Icon(Icons.share, size: 50),<br>                  ),<br>                ],</strong><br>              ],<br>            ),</pre><p>The condition here along with the use of the <strong>spread operator</strong> lets us control the visibility of the widget. Simple isn’t it?. This way, you got rid of multiple Visibility widgets in the widget tree.</p><h4>Relevant Links :</h4><p><strong>👨🏻‍💻 DartPad</strong>: Run the example on DartPad using this <a href="https://dartpad.dev/d9edf44096127c5148e91a7dc0e20633?null_safety=true"><strong>link</strong></a>.</p><p><strong>Official documentation:</strong> For more on the spread operator check out this <a href="https://dart.dev/guides/language/language-tour#spread-operator"><strong>link</strong></a>.</p><p><strong>Bonus 🍪 :</strong></p><p>Here’s a <a href="https://itsallwidgets.com/"><strong>website</strong></a> for you to check out some amazing open-source projects created by the amazing Flutter community. 🙂</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0IycQmt79g9XzOWQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmattcutshall-matt-cutshall-l0IycQmt79g9XzOWQ&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fl0IycQmt79g9XzOWQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/37195f3b21f74b6d6ae05a1e44a721a0/href">https://medium.com/media/37195f3b21f74b6d6ae05a1e44a721a0/href</a></iframe><p><strong>Part 2 : 👇🏻</strong></p><p><a href="https://medium.com/flutter-clan/flutter-quick-bites-part-2-nested-gesturedetector-to-click-or-not-to-click-bbf204c5afc1">Flutter Quick Bites Part 2: Nested GestureDetector, to click or not to click?</a></p><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> , or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66e9f35f3350" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-clan/flutter-quick-bites-part-1-spread-operator-visibility-with-a-twist-66e9f35f3350">Flutter Quick Bites Part 1: Spread Operator, Visibility with a twist.</a> was originally published in <a href="https://medium.com/flutter-clan">Flutter Clan</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being “pedantic” about the code you write — The Flutter way.]]></title>
            <link>https://medium.com/flutter-community/being-pedantic-about-the-code-you-write-the-flutter-way-bc1b7632a296?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc1b7632a296</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Tue, 26 May 2020 05:55:48 GMT</pubDate>
            <atom:updated>2020-06-08T01:44:58.367Z</atom:updated>
            <content:encoded><![CDATA[<h3>Being “pedantic” about the code you write — The flutter way.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cJqukFTF-MGM2pFh" /><figcaption>Photo by <a href="https://unsplash.com/@sctgrhm?utm_source=medium&amp;utm_medium=referral">Scott Graham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We as software engineers tend to write code that follow a certain architecture. We try our best to give our project a structure which makes it scalable i.e. more and more set of features can be added without much adjustment. This is done for the betterment of the whole application and the team involved.</p><p>But what about the minute details we miss out on? Like for example, what if someone in the team writes a conditional code where the “else” is empty. What if someone writes a code where they are unnecessarily using keywords like “this”, “new” or “const”. Will this affect the overall functionality of the module? No. Will this affect the scalability factor of the application? No.</p><p>Then why look into these minute details, one might ask.</p><p>The main reason one might prefer something that keeps a check on minute details, a linter, is <strong>maintainability</strong>. What I mean by maintainability is how related, readable and understandable code is. Maintainability is itself a measure of the ease to modify code, <strong>higher</strong> <strong>maintainability</strong> means less time to make a change. This is generally observed when you start working on a new project or someone new joins your team. In both the situations, you want the new developer (be it you or someone else) to understand the code and the structure of the project as quickly as possible and start contributing at the earliest.</p><p>In flutter, we do have something like this available out of the box. I am talking about <a href="https://github.com/dart-lang/linter">Dart Linter</a>, which is built right into the <a href="https://github.com/dart-lang/sdk/tree/master/pkg/analyzer">Dart Analyzer</a>. You might choose to enable/disable the lints as per your need. The way to decide this is by a lot of trial and errors and choosing the right ones after this tiring process, or having a comprehensive list of lints available with you which the developers at <strong>Google</strong> prefer in their own Dart code.</p><p>Well, I chose the second option and we will be discussing about that next.</p><h3><strong>Pedantic.</strong></h3><p>As per the dictionary, pedantic is someone who is excessively concerned with minor details or rules and the name justifies the use case of this <a href="https://pub.dev/packages/pedantic">Package</a>.</p><p>Enough said. Let’s see how you can add these lint rules to your Flutter project.</p><p><strong>Step 1.</strong></p><p>Add <a href="https://pub.dev/packages/pedantic"><strong>pedantic: 1.9.0</strong></a><strong> </strong>to your <strong>dev_dependencies</strong> inside your <strong>pubspec.yaml</strong> file.</p><p>If you add this, you might face the error of version conflict with the flutter_test package. No worries, just add pedantic: 1.9.0 to your <strong>dependency_overrides</strong> in the <strong>pubspec.yaml.</strong></p><p>Why add this package as a dev dependency? Well, if you just want to enforce the lint rules and are not planning on referencing this dependency inside your code, then just add this as a dev dependency. Otherwise, you do have an option to simply add it to the dependencies.</p><p><strong>Step 2.</strong></p><p>Moving on, we now need a file to have all the lint rules that we want to enforce. The way you do this is by adding a file called <strong>analysis_options.yaml</strong> to the root of you project (where your pubspec.yaml file is). Now, add all the rules you want (I would suggest you add all) from <a href="https://github.com/dart-lang/pedantic/blob/master/lib/analysis_options.1.9.0.yaml">here</a> to the file.</p><p>Your lint rules will likely fail whenever a new version of <strong>package:pedantic</strong> is released. To avoid this, specify a specific version of <strong>analysis_options.yaml</strong> instead</p><pre>include: package:pedantic/analysis_options.1.9.0.yaml</pre><p>This is to be added on top of your <strong>analysis_options.yaml </strong>file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*pKI46I5fBivGhIGRjLLW8g.png" /></figure><p><strong>Step 3.</strong></p><p>Now comes the part where in you will run the static analysis of your code and all the rules that you have mentioned in the file will be enforced.</p><p>Now, there might be a situation wherein your team does not agree with a certain lint rule and would like to disable it. Well, that can easily be done by adding <strong>: false </strong>in front of the dependency. For example:</p><pre>omit_local_variable_types: false</pre><p>This <a href="https://dart-lang.github.io/linter/lints/"><strong>link</strong></a> will help you decide which lint rule you and your team are comfortable with. This gives a detailed info about the lint rules available that too with an easy to understand example.</p><p>After this, simply run the command <strong>flutter analyze </strong>and you will be shown all the rules that are being violated. It will give you the rule name and the path of the file as well.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0IycQmt79g9XzOWQ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmattcutshall-matt-cutshall-l0IycQmt79g9XzOWQ&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0IycQmt79g9XzOWQ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c7bcefdae8699718faacc798b9d9ce2/href">https://medium.com/media/3c7bcefdae8699718faacc798b9d9ce2/href</a></iframe><h3>How many claps does this article deserve?</h3><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>Check out my series on various Flutter widgets here -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc1b7632a296" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/being-pedantic-about-the-code-you-write-the-flutter-way-bc1b7632a296">Being “pedantic” about the code you write — The Flutter way.</a> was originally published in <a href="https://medium.com/flutter-community">Flutter Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Widget Guide — ShaderMask Widget in 5 mins or less]]></title>
            <link>https://medium.com/flutter-community/flutter-widget-guide-shadermask-widget-in-5-mins-or-less-ab9954f526c7?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab9954f526c7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Thu, 05 Mar 2020 13:48:46 GMT</pubDate>
            <atom:updated>2020-03-11T05:20:18.794Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter Widget Guide — ShaderMask Widget in 5 mins or less</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SzxwTyMsXhrSD4_P-IZtHw.png" /></figure><p>This is <strong>Part 19 </strong>in the series where I’ll cover all the Flutter widgets that are in <a href="https://www.youtube.com/watch?v=b_sQ9bMltGU&amp;list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG"><strong>this</strong></a> YouTube playlist. I have created my own widget guide which I believe will help people who are new in this space. Please have a look at this <a href="https://github.com/annshsingh/flutter-widget-guide"><strong>GitHub project</strong></a> to explore all the amazing widgets.</p><p><em>Click </em><a href="https://play.google.com/store/apps/details?id=com.annsh.flutterwidgetguide"><strong><em>here</em></strong></a><em> to </em>⏬<em> the </em><strong><em>App</em></strong><em> available on Google Play Store. </em>📱</p><p>My main motive behind this series is to keep things to the point. Your time is precious, let’s not waste it and get started.</p><p>It is always fun to use Gradients inside your applications. They are visually appealing and helps giving your views a modern look and feel (when used adequately). In flutter, there are ways to give Container widget a gradient using BoxDecoration widget and providing it with Linear, Radial or Sweep gradient. To apply gradient to widgets like Text or Image etc, flutter has a widget prepared for you to use.</p><h3>ShaderMask Widget</h3><h4>1 | What?</h4><p>This widget is helpful when you want to apply shaders to views like a Text widget. You can use this widget to apply Gradients or Images to other widgets just by wrapping them with this and providing a shader you wish to apply.</p><h4>2 | Wondering how it works?</h4><p>Have a look at the Code snippet below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e3dd3ee9f337ebb93855b5bb6153b34/href">https://medium.com/media/0e3dd3ee9f337ebb93855b5bb6153b34/href</a></iframe><p>Below is the visual representation of the code above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*nzB75Ciewrr29z97NjDhVQ.png" /></figure><h4>3 | Explanation</h4><p>In the example above, we have a Text widget and a FlutterLogo widget with Gradients applied to them using ShaderMask widget. It is done by simply wrapping those widgets with ShaderMask and providing it with a Gradient (can be Linear, Radial or Sweep) via its <strong>shaderCallback </strong>property. The shaderCallback is called with the current size of the child of ShaderMask (here, Text and FlutterLogo widgets) so that it can customize the shader to the size and location of the child. The <strong>createShader </strong>method of the Gradient classes in Flutter is used to create a shader using the bounds passed on to the <strong>shaderCallback </strong>property (as can be seen in the code snippet above).</p><p>Also, do keep in mind to pass color as white to the child widgets of ShaderMask to see the desired result.</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-listwheelscrollview-widget-in-5-mins-or-less-c1da452355d2">Flutter Widget Guide — ListWheelScrollView Widget in 5 mins or less</a></p><p><strong>Previous </strong>👆</p><h4>How many claps does this article deserve?</h4><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>See more in the series -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><p>Have a wonderful day 🙂</p><p><a href="https://www.twitter.com/FlutterComm">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab9954f526c7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-widget-guide-shadermask-widget-in-5-mins-or-less-ab9954f526c7">Flutter Widget Guide — ShaderMask Widget in 5 mins or less</a> was originally published in <a href="https://medium.com/flutter-community">Flutter Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Widget Guide — ListWheelScrollView Widget in 5 mins or less]]></title>
            <link>https://medium.com/flutter-community/flutter-widget-guide-listwheelscrollview-widget-in-5-mins-or-less-c1da452355d2?source=rss-964a3b5b9eba------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1da452355d2</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[application-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Annsh Singh]]></dc:creator>
            <pubDate>Thu, 05 Mar 2020 11:30:02 GMT</pubDate>
            <atom:updated>2020-03-11T05:23:33.717Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter Widget Guide — ListWheelScrollView Widget in 5 mins or less</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*896aOmL9-up_HAp7MRzLQA.png" /></figure><p>This is <strong>Part 18 </strong>in the series where I’ll cover all the Flutter widgets that are in <a href="https://www.youtube.com/watch?v=b_sQ9bMltGU&amp;list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG"><strong>this</strong></a> YouTube playlist. I have created my own widget guide which I believe will help people who are new in this space. Please have a look at this <a href="https://github.com/annshsingh/flutter-widget-guide"><strong>GitHub project</strong></a> to explore all the amazing widgets.</p><p><em>Click </em><a href="https://play.google.com/store/apps/details?id=com.annsh.flutterwidgetguide"><strong><em>here</em></strong></a><em> to </em>⏬<em> the </em><strong><em>App</em></strong><em> available on Google Play Store. </em>📱</p><p>My main motive behind this series is to keep things to the point. Your time is precious, let’s not waste it and get started.</p><p>ListView is a very common widget to have in an application. It easily lets you browse through multiple elements that cannot fit on a screen at once. As flutter developers, we all love to go above and beyond what others normally would do with a view. To spice things up in case of a simple, rather boring way of showing elements in a list, Flutter has an interesting widget in store for you.</p><h3>ListWheelScrollView Widget</h3><h4>1 | What?</h4><p>This widget is similar to a ListView but with the restriction that all<br>children must be the same size along the scrolling axis (set using <strong>itemExtent</strong> property). When the list is at the zero scroll offset, the first child is aligned with the middle of the viewport. When the list is at the final scroll offset, the last child is aligned with the middle of the viewport (as can be seen in the GIF below). The elements in this widget are rendered as if rotating on a cylinder in 3D instead of scrolling on a plane like a normal ListView widget.</p><h4>2 | Wondering how it works?</h4><p>Have a look at the Code snippet below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/992fa17df7aa304880d145066e19f99d/href">https://medium.com/media/992fa17df7aa304880d145066e19f99d/href</a></iframe><p>Below is the visual representation of the code above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*2OuA6feDbs48Ykfdleyqkg.gif" /></figure><h4>3 | Explanation</h4><p>In the above example, we have a ListWheelScrollView widget along with a Slider widget. We are feeding the ListWheelScrollView widget with a list of Card widgets generated via its <strong>children </strong>property. Next, we specify the size of each child (in the main axis, here, height) with the <strong>itemExtent </strong>property. This overrides your size constraints that you set for each child, what I mean by this is, you cannot vary height of the cards in our case by wrapping it up with a Container widget and giving it a height. We can set the diameter of the wheel with <strong>diameterRatio </strong>property.</p><p>Here, we are using the Slider widget to change another interesting property of this widget, which is <strong>offAxisFraction. </strong>This property lets you make the wheel off axis. See it in action in the GIF above.</p><p><a href="https://medium.com/flutter-community/flutter-widget-guide-hero-widget-in-5-mins-or-less-3a8d0b479d4a">Flutter Widget Guide — Hero Widget in 5 mins or less</a></p><p><strong>Previous </strong>👆</p><p><strong>Next </strong>👇</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-shadermask-widget-in-5-mins-or-less-ab9954f526c7">Flutter Widget Guide — ShaderMask Widget in 5 mins or less</a></p><h4>How many claps does this article deserve?</h4><p><em>If you find this article useful, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to clap many times (10</em>💥<em>, 20</em>💥<em> or maybe 50</em>💥<em> ?) It fuels my focus to write more of it.</em></p><p>Connect with me on <a href="https://www.linkedin.com/in/annsh/">LinkedIn</a> or say hi on <a href="https://mobile.twitter.com/annsh2013">Twitter</a>, mentioning this article. You can drop an e-mail at annsh29@gmail.com as well.</p><p>See more in the series -</p><p><a href="https://medium.com/@annsh/flutter-widget-guide-index-f03141793b09">Flutter Widget Guide — Index</a></p><p>Have a wonderful day 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1da452355d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-widget-guide-listwheelscrollview-widget-in-5-mins-or-less-c1da452355d2">Flutter Widget Guide — ListWheelScrollView Widget in 5 mins or less</a> was originally published in <a href="https://medium.com/flutter-community">Flutter Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>