<?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 Felipe Belluco on Medium]]></title>
        <description><![CDATA[Stories by Felipe Belluco on Medium]]></description>
        <link>https://medium.com/@felipebelluco?source=rss-eec22f049dca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Mffgkp6e7Wz5zwwquvUsDw.jpeg</url>
            <title>Stories by Felipe Belluco on Medium</title>
            <link>https://medium.com/@felipebelluco?source=rss-eec22f049dca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:35:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@felipebelluco/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[How to create a keyboard shortcut for Apple Intelligence Writing Tools on macOS]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@felipebelluco/how-to-i-create-a-keyboard-shortcut-for-apple-intelligence-writing-tools-on-macos-96ae7b657078?source=rss-eec22f049dca------2"><img src="https://cdn-images-1.medium.com/max/2600/0*Ijsf4xOs0PKNp5aQ" width="6000"></a></p><p class="medium-feed-snippet">If you&#x2019;re anything like me, reaching for the menu every time to access Apple Intelligence&#x2019;s writing tools can be quite annoying and&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@felipebelluco/how-to-i-create-a-keyboard-shortcut-for-apple-intelligence-writing-tools-on-macos-96ae7b657078?source=rss-eec22f049dca------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@felipebelluco/how-to-i-create-a-keyboard-shortcut-for-apple-intelligence-writing-tools-on-macos-96ae7b657078?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/96ae7b657078</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[apple-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 14:56:17 GMT</pubDate>
            <atom:updated>2025-09-16T14:59:11.497Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Move Docker Data to an External Drive on MacOS]]></title>
            <link>https://medium.com/@felipebelluco/how-to-move-docker-data-to-an-external-drive-on-macos-3ca2c35771a3?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ca2c35771a3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Sun, 15 Jun 2025 20:15:15 GMT</pubDate>
            <atom:updated>2025-06-15T20:42:33.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LBwAC1UmZcvfwbuf" /><figcaption>Photo by <a href="https://unsplash.com/@chuttersnap?utm_source=medium&amp;utm_medium=referral">CHUTTERSNAP</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I recently decided to switch back to Apple after two years of working on a Windows PC. After watching several videos on YouTuber, I went with the entry-level Mac mini M4–16GB of RAM and 256GB of internal storage — and planned to use external storage for the heavy stuff. (I’ll list all the accessories I’m using at the end of the article.)</p><p>If you use Docker and have a small internal drive, you’ll eventually hit the dreaded “Your disk is almost full” error. That’s because Docker stores all images, volumes, and a large virtual disk file in its data directory, which can quickly eat up your space.</p><p>This guide walks you through the exact steps to move Docker’s data to an external drive — freeing up your internal storage without sacrificing performance or stability.</p><h4>Identify the Docker Data Directory</h4><p>Before we begin, it’s important to know what we are moving. We are not moving the <strong>Docker application</strong> itself, just the <strong>data directory</strong>, which contains all images, containers, volumes, etc. Moving the app itself can allegedly cause issues with updates and overall system stability, so we definitely want to avoid that.</p><p>The directory path depends on your version of Docker Desktop:</p><ul><li>Version <strong>4.3.0</strong> and above:<br> ~/Library/Group Containers/group.com.docker</li><li>Older versions:<br> ~/Library/Containers/com.docker.docker/Data/vms/0/</li></ul><h4>Quit Docker Desktop</h4><p>To ensure data integrity during the process, you must completely shut down the Docker Desktop Application. Click the Docker icon in the menu bar and select <em>“Quit Docker Desktop”</em>.</p><h4>Move the Docker Data Directory</h4><p>Now open Terminal (you’ll find it in /Application/Utilities) an run the following command to move the data to your external drive:</p><pre># Replace &quot;YourExternalDrive&quot; with the actual name of your drive,<br># and &quot;DockerData&quot; with the desired folder name.<br><br>mv ~/Library/Group\ Containers/group.com.docker /Volumes/YourExternalDrive/DockerData/</pre><p>Depending on how much data Docker has stored, this might take a while.</p><h4>Create a Symbolic Link</h4><p>Now that the data is moved, we’ll create a <strong>symbolic link (symlink)</strong> from the original location to the new one. This makes Docker think its files are still in the default path.</p><p>In terminal, run:</p><pre># Ensure the paths here match the ones you used in the command above.<br><br>ln -s /Volumes/YourExternalDrive/DockerData/group.com.docker ~/Library/Group\ Containers/group.com.docker</pre><p>This command creates the necessary redirection for Docker to find its data.</p><h4>Restart Docker and Verify</h4><p>Start Docker Desktop again. It should now follow the symlink and use the data on your external drive.</p><p>To confirm everything’s working, run:</p><pre>docker run hello-world</pre><p>If the container runs and outputs the <em>“Hello from Docker!”</em> message, you’re good to go. Alternatively, you can try starting any preexisting container directly from the Docker Desktop itself and see if everything runs as expected.</p><p>And that’s it! Docker is now running off your external drive, freeing up a significant amount of space on your internal storage.</p><h4>Gear used</h4><p>For reference, this guide was tested on a Mac Mini M4. The following accessories were used to expand the storage and provide seamless, high-performance experience.</p><ul><li><a href="https://amzn.to/43XPRKc">Ugreen Docking Station for Mac Mini M4</a>: This dock fits perfectly under the Mac mini, expanding the available ports and providing the NVMe slot for the external SSD.</li><li><a href="https://amzn.to/441LkGO">Samsung 990 Evo NVMe SSD</a>: A fast and reliable NVMe SSD that provides excellent performance.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ca2c35771a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter’s Hidden Gem: MergeSemantics]]></title>
            <link>https://medium.com/@felipebelluco/flutters-hidden-gem-mergesemantics-44a06f7f9894?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/44a06f7f9894</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 21:29:13 GMT</pubDate>
            <atom:updated>2023-06-26T21:29:13.579Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEtSU3UujMofXRY4UmVtIw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@benkolde?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ben Kolde</a> na <a href="https://unsplash.com/pt-br/fotografias/cpLsWmMEa1Q?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Unlock the Power of Enhanced Accessibility and Performance in Your Apps</h4><p>Today I’m bringing up to you something that doesn’t usually grab the headlines but is very important — <a href="https://api.flutter.dev/flutter/widgets/MergeSemantics-class.html">MergeSemantics</a>. This widget helps make apps more friendly for people using screen readers, and it also helps the app run smoother. In this article, we’ll take a good look at MergeSemantics, figure out how it works, and talk about ways we can use it to make our Flutter apps even better.</p><h3>What is MergeSemantics?</h3><p>MergeSemantics is a widget in Flutter that helps us manage how our app’s UI elements are understood by screen readers and other assistive technologies. By using MergeSemantics, we can combine the information from several widgets into one. This not only makes screen readers smarter about what they’re reading out, but also helps the app run faster by simplifying the structure of the semantic tree. Here’s how you can use MergeSemantics in your code:</p><pre>MergeSemantics(<br>  child: Row(<br>    children: &lt;Widget&gt;[<br>      Checkbox(<br>        value: true,<br>        onChanged: (bool? value) {},<br>      ),<br>      const Text(&#39;Settings&#39;),<br>    ],<br>  ),<br>)</pre><h3>When to Use MergeSemantics</h3><p>Knowing what a tool does is one thing, but knowing when to use it — that’s where the real skill comes in. So, when should we use MergeSemantics in our Flutter apps? Here are a few situations to consider:</p><h4>Complex Widget Structures</h4><p>If you have a part of your app where many widgets are grouped together to form a more complex widget, using MergeSemantics can be very beneficial. By grouping the semantic data of all the child widgets into one, you can simplify how assistive technologies read them and improve app performance.</p><pre>MergeSemantics(<br>  child: Column(<br>    mainAxisAlignment: MainAxisAlignment.center,<br>    children: [<br>      Text(&#39;This is a complex widget structure&#39;),<br>      SizedBox(height: 10),<br>      Row(<br>        mainAxisAlignment: MainAxisAlignment.center,<br>        children: [<br>          Icon(Icons.check),<br>          SizedBox(width: 5),<br>          Text(&#39;Option 1&#39;),<br>        ],<br>      ),<br>      SizedBox(height: 5),<br>      Row(<br>        mainAxisAlignment: MainAxisAlignment.center,<br>        children: [<br>          Icon(Icons.check),<br>          SizedBox(width: 5),<br>          Text(&#39;Option 2&#39;),<br>        ],<br>      ),<br>    ],<br>  ),<br>)</pre><blockquote>In this example, the MergeSemantics widget is used to merge the semantics of multiple widgets into a single semantic node. This can be helpful when you have complex widget structures like rows and columns, and you want to ensure that the screen reader interprets them correctly.</blockquote><h4>Improving Screen Reader Experience</h4><p>MergeSemantics is a boon when you want to improve the experience for users who rely on screen readers. If you have UI elements that are meant to be read or interacted with as a single unit, using MergeSemantics can ensure a smoother and more coherent experience for these users.</p><pre>MergeSemantics(<br>  child: Column(<br>    mainAxisAlignment: MainAxisAlignment.center,<br>    children: [<br>      Text(&#39;This is a screen reader example&#39;),<br>      SizedBox(height: 10),<br>      ElevatedButton(<br>        onPressed: () {<br>          // Perform some action<br>        },<br>        child: Text(&#39;Click Me&#39;),<br>      ),<br>    ],<br>  ),<br>)</pre><blockquote>In this example, the MergeSemantics widget is used to improve the screen reader experience by grouping related content together. The button’s text and the surrounding text are merged into a single semantic node, allowing the screen reader to present them as a coherent unit.</blockquote><h4>Optimizing App Performance</h4><p>When your semantic tree is getting too deep or complex, it can start to affect the performance of your app. Using MergeSemantics can help you manage the complexity of your semantic tree and keep your app running smoothly.</p><pre>ListView.builder(<br>  itemCount: 1000,<br>  itemBuilder: (context, index) {<br>    return MergeSemantics(<br>      child: ListTile(<br>        title: Text(&#39;Item $index&#39;),<br>        subtitle: Text(&#39;Subtitle $index&#39;),<br>        trailing: Icon(Icons.arrow_forward),<br>        onTap: () {<br>          // Handle item tap<br>        },<br>      ),<br>    );<br>  },<br>),</pre><blockquote>In this example, the MergeSemantics widget is used within a <em>ListView.builder</em> to optimize app performance when dealing with a large number of items. By wrapping each <em>ListTile</em> in a <em>MergeSemantics</em> widget, the individual semantics of each item are merged, reducing the overall number of semantic nodes and improving the app&#39;s performance.</blockquote><h3>Common Mistakes and How to Avoid Them</h3><p>MergeSemantics can be incredibly useful, but like any tool, it can cause issues if not used properly. Let’s talk about some common mistakes developers make with MergeSemantics and how you can avoid them.</p><h4>Overusing MergeSemantics</h4><p><strong>The Mistake:</strong> Some developers get carried away and use MergeSemantics everywhere, thinking it will always improve performance.</p><p><strong>How to Avoid It:</strong> Remember that MergeSemantics should be used thoughtfully. Only use it when you need to group widgets for better accessibility or to genuinely optimize the semantics tree. Unnecessary use can make your codebase more complicated without any real benefit.</p><h4>Not Testing with Actual Screen Readers</h4><p><strong>The Mistake:</strong> Assuming that just using MergeSemantics will automatically make everything accessible, without testing the app with actual screen readers.</p><p><strong>How to Avoid It:</strong> Always test your app with real screen readers to make sure that the semantic grouping makes sense in practice. What seems logical to you might not always translate well for screen reader users.</p><h4>Misunderstanding the Purpose</h4><p><strong>The Mistake:</strong> Using MergeSemantics to try to visually group widgets together.</p><p><strong>How to Avoid It:</strong> MergeSemantics doesn’t affect the visual appearance of widgets; it only affects the semantics tree. If you want to visually group widgets, consider using containers or other layout widgets.</p><h4>Ignoring the Semantic Tree</h4><p><strong>The Mistake:</strong> Not paying attention to how MergeSemantics affects the structure of the semantic tree, leading to unexpected behavior.</p><p><strong>How to Avoid It:</strong> Use Flutter’s debugging tools to inspect the semantic tree and understand how MergeSemantics changes its structure. This will help you make more informed decisions about where and how to use MergeSemantics.</p><h4>Neglecting Nested MergeSemantics</h4><p><strong>The Mistake:</strong> Nesting MergeSemantics widgets without considering how they will interact and what the final semantic data will be.</p><p><strong>How to Avoid It:</strong> Be mindful when nesting MergeSemantics widgets. Make sure to understand how the semantic data will be combined and test thoroughly to ensure the intended behavior.</p><h3>Wrapping things up</h3><p>Before we sign off, let’s acknowledge that MergeSemantics is one of the many widgets in Flutter that doesn’t always get the spotlight but plays a crucial role behind the scenes. It’s a reminder that sometimes the most powerful tools are the ones that quietly make things better. So, let’s give MergeSemantics the love it deserves and use it to build fantastic, inclusive, and high-performance apps.</p><p>Happy coding!</p><p>And hey, if you found this article helpful and want to show some love, consider <a href="https://www.buymeacoffee.com/belluco">buying me a coffee</a>! Cheers and thanks for the support! ☕</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44a06f7f9894" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HttpParams Builder for Angular]]></title>
            <link>https://medium.com/@felipebelluco/httpparams-builder-for-angular-f885aa0a68d2?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/f885aa0a68d2</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 23:18:18 GMT</pubDate>
            <atom:updated>2022-04-15T23:18:18.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJvm0lXmieXX-Cz4-KXOdA.jpeg" /></figure><p>Greetings,</p><p>Today I was revisiting the code of an Angular project I’m working on, and I went through the following piece of code in a service class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ace13934a6de89290d4ace5872026d5/href">https://medium.com/media/3ace13934a6de89290d4ace5872026d5/href</a></iframe><p>As you may know, the HttpParams is an immutable class used to declare the query params passed on a http request using HttpClient.</p><p>And because of the HttpParams immutability aspect, its instance doesn’t change, instead, every time I call .append(...) a new instance is created. So I have to reassign the params variable with the new instance.</p><p>params = params.append(&#39;uf&#39;, filter.uf);</p><p>Although necessary, it doesn’t look very nice. So I came up with a builder to keep things cleaner, and turn the code above in to the this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4095b3abf14ad0b966a743769b90bf39/href">https://medium.com/media/4095b3abf14ad0b966a743769b90bf39/href</a></iframe><p>In my opinion, it looks more concise. Here’s the implementation of the HttpParamsBuilder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c87f05889e646f3bc96d0ff95b1792f8/href">https://medium.com/media/c87f05889e646f3bc96d0ff95b1792f8/href</a></iframe><p>Let me know your thoughts!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f885aa0a68d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add ADB to PATH on OSX]]></title>
            <link>https://medium.com/macoclock/add-adb-to-path-on-osx-8bc2f11a19ea?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bc2f11a19ea</guid>
            <category><![CDATA[os-x]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Sun, 01 Mar 2020 23:10:39 GMT</pubDate>
            <atom:updated>2020-03-30T22:29:01.088Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZ8l6zTznQz0kxNfh-K04A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@blakeconnally?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Blake Connally</a> on <a href="https://unsplash.com/s/photos/macbook-programming?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>If you are an Android developer you probably needed to use ADB to do things like listing connected devices or connect to a physical device over wi-fi, and so on. This short post intends to explain how to add ADB as a PATH variable on OSX. Without further ado, with the Terminal app opened, do the following:</p><p>Make sure to be in the <strong>Home </strong>directory</p><pre>cd ~</pre><p>To persist PATH changes and prevent it to be cleaned up after closing the Terminal app, you need to keep the variables in the bash_profile file for OS before Catalina and zshrc file for Catalina. So, let&#39;s create it</p><pre>// prior Catalina<br>touch .bash_profile</pre><pre>// Catalina<br>touch .zshrc</pre><p>Open it with the TextEditor</p><pre>// prior Catalina<br>open -e .bash_profile</pre><pre>// Catalina<br>open -e .zshrc</pre><p>Insert the command below to add ADB as PATH variable (replace username with your own)</p><pre>export PATH=$PATH:/Users/username/Library/Android/sdk/platform-tools/</pre><p>Save the file and close the TextEditor app. Back to the Terminal app, insert the following to source the file</p><pre>// prior Catalina<br>source .bash_profile</pre><pre>// Catalina<br>source .zshrc</pre><p>And you’re done! Let’s test if it was successful</p><pre>adb version</pre><p>You should expect something like</p><pre>Android Debug Bridge version 1.0.36</pre><pre>Revision 0e9850346394-android</pre><p>Have a nice code! ☕</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bc2f11a19ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/macoclock/add-adb-to-path-on-osx-8bc2f11a19ea">Add ADB to PATH on OSX</a> was originally published in <a href="https://medium.com/macoclock">Mac O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Picking images with Flutter]]></title>
            <link>https://medium.com/@felipebelluco/picking-images-with-flutter-33c23554589a?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/33c23554589a</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Wed, 22 Jan 2020 01:57:22 GMT</pubDate>
            <atom:updated>2020-01-22T01:57:22.611Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2P-m9Ig596QttbRIrzmD-g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jakobowens1?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jakob Owens</a> on <a href="https://unsplash.com/s/photos/picking-image?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I recently had to add a picking image feature in one of the projects I’m working on, and I was amazed by how easy it’s to accomplish such a thing.</p><p>For this post, I’ll assume that you have Flutter properly set up and, know how to create a project and know the basics of Flutter.</p><blockquote>The important parts of the code will be highlighted!</blockquote><h4>Complementary lib</h4><p>The <a href="https://pub.dev/packages/image_picker">image_picker </a>is the only complementary lib we’ll be using through this post. Here’s my <em>pubspec</em> file for reference:</p><pre>name: image_picker_sample<br>description: A new Flutter application.<br><br>version: 1.0.0+1<br><br>environment:<br>  sdk: &quot;&gt;=2.1.0 &lt;3.0.0&quot;<br><br>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  cupertino_icons: ^0.1.2<br>  <strong>image_picker: 0.6.1</strong><br><br>dev_dependencies:<br>  flutter_test:<br>    sdk: flutter<br><br>flutter:<br>  uses-material-design: true</pre><h4>App Structure</h4><p>Besides the main class, the app will have two other classes representing the pages, one for picking the image and one for showing your choosing and one class for holding the image file while we navigate between the pages.</p><h4>Picking the image</h4><pre><em>import </em>&#39;package:flutter/material.dart&#39;;<br><em>import </em>&#39;package:image_picker_sample/pick_image_page.dart&#39;;<br><em>import </em>&#39;package:image_picker_sample/view_image_page.dart&#39;;<br><br><em>void </em>main() =&gt; runApp(MyApp());<br><br><em>class </em>MyApp <em>extends </em>StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    <em>return </em>MaterialApp(<br>      title: &#39;Flutter Demo&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: PickImagePage(),<br>      <strong>routes: {<br>        &#39;/pick-image&#39;: (content) =&gt; PickImagePage(),<br>        &#39;/view-image&#39;: (content) =&gt; ViewImagePage()<br>      },</strong><br>    );<br>  }<br>}</pre><p>As you may notice, the main file is pretty much default, the only thing I added was the routes for our two pages.</p><pre><em>import </em>&#39;dart:io&#39;;<br><br><em>import </em>&#39;package:flutter/cupertino.dart&#39;;<br><em>import </em>&#39;package:flutter/material.dart&#39;;<br><em>import </em>&#39;package:image_picker/image_picker.dart&#39;;<br><em>import </em>&#39;package:image_picker_sample/image_args.dart&#39;;<br><br><em>class </em>PickImagePage <em>extends </em>StatefulWidget {<br>  @override<br>  State&lt;StatefulWidget&gt; createState() =&gt; PickImagePageState();<br>}<br><br><em>class </em>PickImagePageState <em>extends </em>State&lt;PickImagePage&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    <em>return </em>Scaffold(<br>      appBar: AppBar(title: Text(&#39;Pick image&#39;)),<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            RaisedButton(<br>              child: Text(&#39;Pick from gallery&#39;),<br>              onPressed: () =&gt; <strong>_pickImage(ImageSource.gallery)</strong>,<br>            ),<br>            RaisedButton(<br>              child: Text(&#39;Pick from camera&#39;),<br>              onPressed: () =&gt; <strong>_pickImage(ImageSource.camera)</strong>,<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br><br>  <strong>_pickImage(ImageSource imageSource) <em>async </em>{<br>    File image = <em>await </em>ImagePicker.<em>pickImage</em>(source: imageSource);<br>    <em>if </em>(image != <em>null</em>) {<br>      Navigator.<em>pushNamed</em>(context, &#39;/view-image&#39;, arguments: ImageArgs(image));<br>    }<br>  }</strong><br>}</pre><p>This page consists of two buttons; one for picking images from the gallery and one for picking using the camera.</p><pre><strong>ImagePicker.<em>pickImage</em>(source: imageSource)</strong></pre><p>The <strong>ImagePicker </strong>class has a static method that receives a <strong>ImageSource </strong>of two values, gallery and camera. This method returns a File promise, which can be the <strong>image</strong> you picked or <strong>null </strong>if you cancel the process along the way.</p><pre><em>import </em>&#39;dart:io&#39;;<br><br><em>class </em>ImageArgs {<br>  <em>final </em>File image;<br><br>  ImageArgs(<em>this</em>.image);<br>}</pre><p>In this example, after getting the file we will redirect to another page passing the file as an argument. To accomplish that we will create the <strong>ImageArgs</strong> class that will encapsulate this information.</p><pre><strong>Navigator.<em>pushNamed</em>(context, &#39;/view-image&#39;, arguments: ImageArgs(image));</strong></pre><p>This will navigate to the page we set up in the app routes in the main class.</p><h4>Viewing the image</h4><pre><em>import </em>&#39;package:flutter/material.dart&#39;;<br><br><em>import </em>&#39;image_args.dart&#39;;<br><br><em>class </em>ViewImagePage <em>extends </em>StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    <strong><em>final </em>ImageArgs args = ModalRoute.<em>of</em>(context).settings.arguments;</strong><br><br>    <em>return </em>Scaffold(<br>      appBar: AppBar(title: Text(&#39;View Image&#39;)),<br>      body: Center(<br>        child: Padding(<br>          padding: <em>const </em>EdgeInsets.all(8.0),<br>          child: <strong>Image.file(args.image),</strong><br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>This page only renders the image we’re passing as argument.</p><h4>Conclusion</h4><p>As you can see, it’s pretty easy to pick images in Flutter apps!</p><p>Have a nice code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33c23554589a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Runtime Android Permissions com Kotlin]]></title>
            <link>https://medium.com/@felipebelluco/runtime-android-permissions-com-kotlin-f140748f98d2?source=rss-eec22f049dca------2</link>
            <guid isPermaLink="false">https://medium.com/p/f140748f98d2</guid>
            <category><![CDATA[android-permissions]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Felipe Belluco]]></dc:creator>
            <pubDate>Fri, 28 Sep 2018 18:13:29 GMT</pubDate>
            <atom:updated>2018-09-28T23:54:53.307Z</atom:updated>
            <content:encoded><![CDATA[<h3>Solicitando Permissão Android em Tempo de Execução com Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oc4pOoEeR_QMrCA6LkF5Kw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/w33-zg-dNL4?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Rami Al-zayat</a> on <a href="https://unsplash.com/search/photos/android-permission?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Nesse artigo vou cobrir o básico sobre como pedir permissão em tempo de execução nos dispositivos com Android 6 (<em>Marshmallow</em>) em diante. Para simplificar vou considerar para todos os exemplos a permissão CALL_HOME, responsável por permitir que o app possa realizar ligação.</p><h4>Etapas</h4><p>A requisição de permissão em tempo real pode ser dividida em duas etapas: antes e depois da requisição.</p><p>Antes da requisição precisamos verificar os seguintes itens:</p><ul><li>Se a permissão não foi concedida.</li><li>Se o usuário já negou a permissão anteriormente.</li></ul><p>Depois da requisição precisamos verificar os seguintes itens:</p><ul><li>Se o usuário concedeu a permissão.</li><li>Se o usuário negou acesso a permissão.</li><li>Se o usuário, além de ter negado, marcou o <em>checkbox</em> “não perguntar novamente”.</li></ul><h4>Passo 1: Verificar se a permissão ainda não foi concedida</h4><p>Antes de pedir permissão é interessante garantir que o usuário ainda não a concedeu. Caso tenha concedido, nada o impede de utilizar a funcionalidade requerida.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d98017dbce9f4bb1496f3a8c59b00527/href">https://medium.com/media/d98017dbce9f4bb1496f3a8c59b00527/href</a></iframe><h4>Passo 2: Verificar se o usuário já negou a permissão anteriormente</h4><p>Após constatar que o usuário não concedeu a permissão, é importante verificar se o usuário não negou a permissão anteriormente.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5582361bd56cba07195b9518fc204657/href">https://medium.com/media/5582361bd56cba07195b9518fc204657/href</a></iframe><p>Caso essa seja a primeira vez que o usuário tente acessar a funcionalidade basta fazer a requisição.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a571daf47ba3cd692b3b7e8d8a875c7f/href">https://medium.com/media/a571daf47ba3cd692b3b7e8d8a875c7f/href</a></iframe><p>Veja que é necessário criar uma constante do tipo Int para identificar a requisição quando for tratá-la.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac4bfa393b06b3711da84d18f020db21/href">https://medium.com/media/ac4bfa393b06b3711da84d18f020db21/href</a></iframe><p>Caso o usuário já tenha recusado a permissão é interessante mostrar para o usuário a importância de liberar o acesso a funcionalidade. Uma boa forma de fazer isso é através de um <a href="https://developer.android.com/guide/topics/ui/dialogs">AlertDialog</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e92f4879c24cee2bed4620845dd72b40/href">https://medium.com/media/e92f4879c24cee2bed4620845dd72b40/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FvR7SgMPlYrtiUowgGngjw.png" /></figure><h4>Passo 3: Verificar se o usuário concedeu a permissão</h4><p>A partir de agora veremos as etapas após a requisição da permissão. Para isso é necessário implementar o método onRequestPermissionResult.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c98eac5b150e3441dee91e1975982d4/href">https://medium.com/media/4c98eac5b150e3441dee91e1975982d4/href</a></iframe><p>Para verificar se a permissão foi concedida precisamos analisar a variável grantResults. Se a variável não estiver vazia e o resultado for igual a PackageManager.PERMISSION_GRANTED significa que o usuário concedeu a permissão.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/975924a1f0357493d2c071d4cab80dea/href">https://medium.com/media/975924a1f0357493d2c071d4cab80dea/href</a></iframe><h4>Passo 4: Verificar se o usuário negou acesso a permissão</h4><p>Se a variável estiver vazia ou o resultado for igual a PackageManager.PERMISSION_DENIED significa que o usuário não concedeu a permissão. Nesse caso você pode mostrar novamente uma mensagem explicando a importância da permissão para o app ou limitar acesso à funcionalidade dentro do app.</p><h4>Passo 5: Verificar se o usuário marcou o <em>checkbox</em> “não perguntar novamente”</h4><p>Quando o usuário negar a permissão e marcar o <em>checkbox</em> “Não perguntar novamente” o app não conseguirá mais solicitar a permissão.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7F6nJVrpYOioiIVggVCmow.png" /></figure><p>Para verificar se o usuário marcou a <em>checkbox</em> é necessário adicionar mais uma condição e utilizar novamente o método utilizado no passo 2. Só que dessa vez com a lógica invertida.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9c7f17ee3bf0d3a0a96de128896887c/href">https://medium.com/media/c9c7f17ee3bf0d3a0a96de128896887c/href</a></iframe><p>Nesse caso você pode mostrar novamente um <a href="https://developer.android.com/guide/topics/ui/dialogs">AlertDialog</a> informando a importância de ter acesso à funcionalidade, mas que dessa vez como o app já não pode mais requerer a funcionalidade a ação positiva do usuário o leva para a tela de detalhe do app dentro do sistema, onde o usuário pode conceder manualmente a permissão.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbd6c889d508a3821e85d86d48a5208e/href">https://medium.com/media/cbd6c889d508a3821e85d86d48a5208e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9ECLzy4y7TM39OvEU7syQ.png" /></figure><h4>Conclusão</h4><p>Seguindo esses passos você terá coberto praticamente todos os cenários de uma requisição de permissão em tempo de execução. É possível ir mais além e fazer requisição de múltiplas permissões ao mesmo tempo. Esse assunto fica para um próximo artigo!</p><p><a href="https://github.com/felipebelluco/AndroidRuntimePermissionWithKotlin">felipebelluco/AndroidRuntimePermissionWithKotlin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f140748f98d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>