<?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 Daniele Cambi on Medium]]></title>
        <description><![CDATA[Stories by Daniele Cambi on Medium]]></description>
        <link>https://medium.com/@dancam.dev?source=rss-b2723c3a8722------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*EEoUuPKZVITb4leK.</url>
            <title>Stories by Daniele Cambi on Medium</title>
            <link>https://medium.com/@dancam.dev?source=rss-b2723c3a8722------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:14:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dancam.dev/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[Must have VS Code extensions for working with Flutter]]></title>
            <link>https://medium.com/flutter-community/must-have-vs-code-extensions-for-working-with-flutter-e31a421b9c68?source=rss-b2723c3a8722------2</link>
            <guid isPermaLink="false">https://medium.com/p/e31a421b9c68</guid>
            <category><![CDATA[vs-code-extensions]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Daniele Cambi]]></dc:creator>
            <pubDate>Thu, 08 Aug 2019 10:01:01 GMT</pubDate>
            <atom:updated>2019-08-08T10:01:01.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>Must-have VS Code extensions for working with Flutter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bB2YSy9CKPe-F0733InQxA.png" /></figure><p>Mobile app development is hard and time-consuming enough for us developers to waste time on importing libraries or having to reformat a dart file manually. <br>In this article we’ll take a look at some VS Code extensions that can greatly improve our workflow and help us reduce the time we waste on boring and repetitive tasks that, added together, take up a lot of our time and productivity.</p><p>So without further ado, let’s get started with the first extension.</p><h4>Flutter and Dart</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*hYarJO-Mksj5YT_AvaeucA.png" /></figure><p>We’re starting with an obvious but crucial one, these are the extensions you most likely already have installed when you set up your Flutter environment the first time. The Flutter extension adds support for editing, refactoring, running and reloading flutter apps.</p><p>I suggest you go in the settings and enable the <strong>Dart:Preview Flutter Ui Guides</strong> option. That will make it really easy to spot the parent-child relationships in your code, which is particularly useful when you have many nested widgets in your UI files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLb49HdT5yZV5YkrE_HpPA.png" /></figure><p>Another thing that this extension allows you to do is to perform multiple useful actions via a menu accessible by pressing ⌘ + . (ctrl + .) on Windows and Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAHHDyzYZzDUnmBROAhgAA.png" /></figure><p>With regard to the Dart extension it basically adds support for the Dart programming language, syntax highlighting and code completion.</p><h4>Bracket Pair Colorizer 2</h4><p>In Flutter we are often dealing with a huge amount of brackets. When you start nesting widgets it can become difficult to spot bracket pairs in a quick and easy way. Look no further than Bracket Pair Colorizer 2 to improve your code readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*XIKVVhdpIl-LXFgPr7Krwg.png" /></figure><h4>Pubspec Assist</h4><p>One of the main setbacks I encountered when I started working with flutter was importing and keeping packages updated. Every time I needed to update a package, I had to go to pub.dev, search for the package, go to the install tab and copy/paste a line of code. As I mentioned in the introduction to this article, we can’t afford to waste time on these things.<br>This is where the extension called pubspec assist comes into play. All you have to do it’s open your pubspec.yaml file, open the command palette, select “pubspec assist: add dependency” and type the name of the dependency you need. You’ll have it automatically added to your pubspec.yaml file, updated to the latest version, all without leaving vs code at all. The following gif will explain it much better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OOLsrjZOjFx2JBm202fIsQ.gif" /></figure><h4>Material Icon Theme</h4><p>The theme of our IDE is often underestimated. It is not a mere aesthetic feature. It actually helps us to find files and folder way quicker. When it comes to VS Code, my theme of choice is the Material Icon Theme by Philipp Kief. It has a huge asset of colored, great looking icons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzKgVVOBeYnLe1MBhK6HEg.png" /></figure><h4>Better comments</h4><p>Commenting code is often useful to leave notes to other developers working on our team, or to our future self. I often use a lot of TODOs for reminding myself to get back on that stuff and refactor for example. Well, better comments helps me a lot. It allows us to categorize our comments based on their type. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*RkAV56DHg7Ah3Fg7q9CwtA.png" /></figure><h4>Todo tree</h4><p>Speaking of TODOs, Todo Tree by Gruntfuggly is one of my favorite extensions while working, not only in flutter, but in VS Code in general. It searches for TODO and FIXME tags within your code and displays those comments in convenient Tree view in the explorer pane, allowing you to directly go to that comment when you click on it. A simple, yet so powerful extension that saves me so much time looking for todos around my code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijPL-spzjGzaBwdNMCKynw.png" /></figure><h4>Color Highlight</h4><p>Color highlight by Sergii Naumov helps out a lot while building the UI and storing color variables to quickly spot which color the hexadecimal value refers to. Color Highlight offers different marker types.<br>In the image there my marker of choice, the ‘background’. Available are also the following markers you’ll need to change in the extensions’ settings: dot-before, dot-after, foreground, outline and underline. Really neat extension for building UIs in a quicker and efficient way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*yUve4g2v9PmCbBz9pt9XvQ.png" /></figure><h4>Image Preview</h4><p>Image Preview by Kiss Tamás it’s especially useful for us Flutter developers. One crucial part of our apps’ experience are images. Images make the app more engaging to users. But as you may know, importing images in Flutter is kind of a pain. You have to import them in a directory, and use a path String to refer to the image every time you want to use it, intelli sense doesn’t help with it either. Image preview allows us at least to have a preview of the image we wrote the path of on the left side of the code line. Much similar as Android Studio and Intellij does for both, images and colors.<br>On top of that, if you hover with the mouse on the path String, the extension shows a link to get to the file in the project structure and its dimensions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NLLicSxcrqntl_8IyXQUWA.png" /></figure><h4>Conclusion</h4><p>This concludes my picks for the top VS Code extensions for Flutter. All of these extensions, thanks to their great creators help me and many other devs out there, to get their job done in a faster and more pleasant way.<br>I hope you enjoyed this article and if you have more extensions you think are useful to me and other flutter devs, please write about them in a response to this article, possibly with a quick description. Let’s improve each other’s workflow!</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=e31a421b9c68" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/must-have-vs-code-extensions-for-working-with-flutter-e31a421b9c68">Must have VS Code extensions for working with Flutter</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 — Making Phone calls, sending SMS and emails with url_launcher]]></title>
            <link>https://medium.com/flutter-community/flutter-making-phone-calls-sending-sms-and-emails-with-url-launcher-56414b06f84e?source=rss-b2723c3a8722------2</link>
            <guid isPermaLink="false">https://medium.com/p/56414b06f84e</guid>
            <category><![CDATA[url]]></category>
            <category><![CDATA[phone]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[sms]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Daniele Cambi]]></dc:creator>
            <pubDate>Sat, 06 Jul 2019 10:01:01 GMT</pubDate>
            <atom:updated>2019-07-06T10:01:01.098Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Making Phone calls, sending SMS and emails with url_launcher</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qPMUcYKLvZAhbvcJeuoLg.png" /></figure><p>Depending on the type of app you are developing, you might want the user to quickly make a call or send a message or email by pressing a button in your app. This might be useful for example if you want him to contact a support line, or if you want to let him call a store or a restaurant.</p><h4>Adding the url_launcher package</h4><p>In order to do all the above mentioned we’re going to need to import a single library which is called url_launcher, you might have used it already to launch websites on safari or chrome from your flutter app. If you haven’t already, let’s add it to our pubspec.yaml file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d37dd5ef7a4c9f6164f63784a74103/href">https://medium.com/media/13d37dd5ef7a4c9f6164f63784a74103/href</a></iframe><h4>Creating the calls and messages service</h4><p>In our services folder, let’s create a calls_and_messages_service.dart file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6471b33a9663f51067327e03fb23935/href">https://medium.com/media/d6471b33a9663f51067327e03fb23935/href</a></iframe><p>This should be pretty self-explanatory, the thing to place attention to is the URL format.</p><ul><li>tel: followed by the number will open the default phone app</li><li>sms: followed by the number will open the default messages app</li><li>mailto: followed by the email will open the default email app</li></ul><h4>As always, our service_locator</h4><p>In order to instantiate the CallsAndMessagesService and have it available quickly anywhere in our app, we want to create a service locator using get_it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e6500690bbfefd2913beb6d3a9f27a4/href">https://medium.com/media/3e6500690bbfefd2913beb6d3a9f27a4/href</a></iframe><p>And don’t forget to call setupLocator in the main function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e073b1f7cc98006f0773273baf2f9269/href">https://medium.com/media/e073b1f7cc98006f0773273baf2f9269/href</a></iframe><h4>Getting the service</h4><p>In order to have access to out CallsAndMessagesService we call it using the locator.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a73fca8b4d251f0d7d7d02ae6673a0fa/href">https://medium.com/media/a73fca8b4d251f0d7d7d02ae6673a0fa/href</a></iframe><h4>Creating a quick UI and calling the respective methods</h4><p>Wrapping it up, let’s create a column of three buttons each for the feature we previously implemented.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af87310d9a8a3ac18abd96502eecdce3/href">https://medium.com/media/af87310d9a8a3ac18abd96502eecdce3/href</a></iframe><h4>GitHub link for the code shown in this article</h4><p>All the code in this article is available at <a href="https://github.com/dancamdev/flutter_calls_messages_and_more">this GitHub link.</a></p><h4>Conclusion</h4><p>This was a quick snippet in order to allow you to make phone calls, send SMS and emails from your flutter app. I hope you enjoyed this snippet!</p><h4>About the author</h4><p>You can find me on</p><ul><li>Instagram: Daniele Cambi (<a href="https://www.instagram.com/dancamdev/">https://www.instagram.com/dancamdev/</a>)</li><li>Twitter: <a href="http://twitter.com/dancamdev">@dancamdev</a> (<a href="https://twitter.com/dancamdev">https://twitter.com/dancamdev</a>)</li><li>Email: <a href="/service/mailto:dancam.dev@gmail.com">dancam.dev@gmail.com</a></li></ul><p>Daniele Cambi (<a href="http://twitter.com/dancamdev">@dancamdev</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56414b06f84e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-making-phone-calls-sending-sms-and-emails-with-url-launcher-56414b06f84e">Flutter — Making Phone calls, sending SMS and emails with url_launcher</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 — Local Authentication with Fingerprint and Face recognition]]></title>
            <link>https://medium.com/flutter-community/flutter-local-authentication-with-fingerprint-and-face-recognition-744d5d7f6c4?source=rss-b2723c3a8722------2</link>
            <guid isPermaLink="false">https://medium.com/p/744d5d7f6c4</guid>
            <category><![CDATA[face-id]]></category>
            <category><![CDATA[fingerprint]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[touch-id]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Daniele Cambi]]></dc:creator>
            <pubDate>Sun, 30 Jun 2019 17:51:05 GMT</pubDate>
            <atom:updated>2019-07-01T06:49:44.063Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Flutter — Local Authentication with Fingerprint and Face recognition</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OYfoTcTLhtXgZiWzUWGhQ.png" /></figure><p>Many users rely on fingerprint or face recognition authentication to enable secure access to their devices. Sometimes we might want to use the same authentication mechanism to allow the user access to our app, or part of it, in a secure and effortless way.</p><p>While working on a project of mine, I needed to implement this feature, I gave the user a protection option in the settings which will basically ask for a fingerprint or face recognition authentication before he’d be able to access the app data.</p><p>In this article, we’re going to implement this feature using the local_auth library, it is going to work seamlessly on both, Android and iOS and we’ll implement it as a service using get_it.</p><h4><strong>Adding local_auth to our project</strong></h4><p>First of all, let’s start by importing the local_auth and get_it library to our pubspec.yaml.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41275e43ef10f208a7facee25631277c/href">https://medium.com/media/41275e43ef10f208a7facee25631277c/href</a></iframe><h4><strong>Setting up our LocalAuthenticationService</strong></h4><p>In our service folder, create a local_authentication_service.dart file and populate it with the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fec96c87c36c0d077ecb5018d8956dd4/href">https://medium.com/media/fec96c87c36c0d077ecb5018d8956dd4/href</a></iframe><ul><li><strong>_auth</strong> variable simply instantiates the LocalAuthentication library, nothing special here.</li><li><strong>bool _isProtectionEnabled</strong> keeps track of the respective setting, in a real-world app, it should be stored in the shared preferences, although it goes beyond the scope of this article.</li><li><strong>isAuthenticated</strong> variable will keep track of the authentication</li></ul><p>Finally, the authenticate method launches the authentication flow with the OS related dialog.</p><p>The stickyAuth property is set to true, so the plugin does not return failure if the app is put to the background by the system. An example might be if the user receives a call before they get the chance to authenticate. With the stickyAuth property set to false, the plugin would return failure to our dart code.</p><h4><strong>Setting up the service locator</strong></h4><p>Create a service_locator.dart file in our services folder and register the LocalAuthentication singleton as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24bf5e706288b91257a6132d9c09da93/href">https://medium.com/media/24bf5e706288b91257a6132d9c09da93/href</a></iframe><p>Call the seupLocator() function from your main function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86b8283ad8025b7bc40fa08d2c12b876/href">https://medium.com/media/86b8283ad8025b7bc40fa08d2c12b876/href</a></iframe><h4><strong>Android Integration</strong></h4><p>In order to have the authentication working correctly on android, we have to do basically two things.</p><p>First, we’ve got to update the AndoridManifest.xml file to include the USE_FINGERPRINT permission as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f0b10460f4516421eaa6ce4b972dcfa/href">https://medium.com/media/2f0b10460f4516421eaa6ce4b972dcfa/href</a></iframe><p>Secondly, in our android app’s MainActivity.java file we have to change the extended class from FlutterActivity to FlutterFragmentActivity, with the relative import.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed5529d43c8b3351a540f3e5a0351f66/href">https://medium.com/media/ed5529d43c8b3351a540f3e5a0351f66/href</a></iframe><h4><strong>iOS Integration</strong></h4><p>The local_auth plugin works with both, TouchID and FaceID. However, for the latter, we need to add the following key-value pair to the info.plist file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d04be15d4958e16b169dde417b142f8/href">https://medium.com/media/6d04be15d4958e16b169dde417b142f8/href</a></iframe><h4><strong>Building a basic UI for the example</strong></h4><p>We’re pretty much done with the logical part. Let’s quickly build the UI in order to test it out.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74d935df4f60c3a8deffd45597f7f690/href">https://medium.com/media/74d935df4f60c3a8deffd45597f7f690/href</a></iframe><p>The UI consists of a simple centered button, the important code is the LocalAuthenticationService that is gotten using the locator, and the authenticate method called in the onPressed of the button.</p><h4><strong>Considerations</strong></h4><p>In the LocalAuthenticationService the isAuthenticated variable will be false in the following cases.</p><ul><li>The user hasn’t been authenticated yet</li><li>The user canceled the authentication</li><li>The authentication failed too many times (fingerprint not recognized)</li></ul><p>It is going to be true when the user is authenticated successfully. In a real-world app, it might be useful to handle these as you see fit.</p><h4>GitHub link for the code shown in this article</h4><p>All the code I have put in this article along with examples on how to use it are available at <a href="https://github.com/dancamdev/flutter_local_authentication">this link on GitHub</a>.</p><h4><strong>Conclusion</strong></h4><p>This as been a quick article/snippet in order to get you started with the local authentication flow in flutter. I hope you enjoyed the article and that it helped you build a secure flutter app!</p><h4>Who are you and where can I contact you?</h4><p>You can find me on</p><ul><li>Instagram: Daniele Cambi (<a href="https://www.instagram.com/dancamdev/">https://www.instagram.com/dancamdev/</a>)</li><li>Twitter: <a href="http://twitter.com/dancamdev">@dancamdev</a> (<a href="https://twitter.com/dancamdev">https://twitter.com/dancamdev</a>)</li><li>Email: dancam.dev@gmail.com</li></ul><p>Daniele Cambi (dancamdev)</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=744d5d7f6c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-local-authentication-with-fingerprint-and-face-recognition-744d5d7f6c4">Flutter — Local Authentication with Fingerprint and Face recognition</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 — Bouncing button animation]]></title>
            <link>https://medium.com/flutter-community/flutter-bouncing-button-animation-ece660e19c91?source=rss-b2723c3a8722------2</link>
            <guid isPermaLink="false">https://medium.com/p/ece660e19c91</guid>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Daniele Cambi]]></dc:creator>
            <pubDate>Fri, 24 May 2019 22:01:00 GMT</pubDate>
            <atom:updated>2019-05-25T22:07:55.674Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Bouncing button animation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAKGyMNlZNWcs0ux9N8WIw.png" /></figure><p>How many times in your experience as a user have you clicked a non-animated button multiple times because you didn’t know if it actually had sent the action you requested? How many times did you do the same thing if the button had even a slight animation telling you it was actually clicked?</p><h4>What is an animation and why do we use them?</h4><p>When it comes to creating a good user experience for your app, adding well made and fluid animations is crucial. They work as a visual feedback for the user’s actions and can also provide meaning of interaction and reassurance.</p><p>Animating buttons is what this article is about, specifically we’ll build a small bouncing animation that is triggered when the user clicks a button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*MxFFYeoBvYa6WVa9l6WEVg.gif" /></figure><h4>First of all, the button layout</h4><p>The button layout is based on a simple container with a text widget in its center.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fc05fc1b415ed307c48686556c8a5b2/href">https://medium.com/media/1fc05fc1b415ed307c48686556c8a5b2/href</a></iframe><h4>Let’s get to the animation</h4><p>We will need to use the setState() and dispose() function, therefore we will extends a StatefulWidget.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a371c6db25eba864a8122b85282746d/href">https://medium.com/media/5a371c6db25eba864a8122b85282746d/href</a></iframe><p>We’re all set to start working on our animation.</p><p>Lets implement SingleTickerProviderStateMixin and define the only two properties which we’ll need to create the animation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7b17f3e0346b15507f208d0cea827b8/href">https://medium.com/media/a7b17f3e0346b15507f208d0cea827b8/href</a></iframe><p>It’s now time to initialize our _controller by overriding initState() and dispose of it by overriding the dispose() function</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5cc89b8e2ddc8a85cadd8bcd8c87528/href">https://medium.com/media/c5cc89b8e2ddc8a85cadd8bcd8c87528/href</a></iframe><p>Next, we’re defining two functions, one for when the button is tapped down, and the other for when the button is released, the former will tell our controller to go forward, and the latter to go in reverse</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf57a8ad243e31afbe6fbce813b9398e/href">https://medium.com/media/cf57a8ad243e31afbe6fbce813b9398e/href</a></iframe><p>Finally, in our build function we set our scale variable and let a GestureDetector handle the tapDown and tapUp properties and then scale using the Transform widget</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dcfad60ac9335d5bb3e0e1bcbb7452b/href">https://medium.com/media/4dcfad60ac9335d5bb3e0e1bcbb7452b/href</a></iframe><p>And this is the final result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*MxFFYeoBvYa6WVa9l6WEVg.gif" /></figure><h4>Where can I find the code?</h4><p>The code written in this article is available at the following <a href="https://github.com/dancamdev/article_bouncing_button_animation">GitHub Repo</a></p><h4>Conclusion</h4><p>That’s all folks! This was a quick article on how to create a simple yet effective animation, that I hope will help you improve your app UX.</p><h4>About the author</h4><p>You can find me on</p><p>- Instagram: <a href="https://www.instagram.com/dancamdev/">Daniele Cambi</a><br>- Twitter: <a href="https://twitter.com/dancamdev">@dancamdev</a><br>- Email: <a href="/service/mailto:dancam.dev@gmail.com">dancam.dev@gmail.com</a></p><p>Daniele Cambi (<a href="http://twitter.com/dancamdev">@dancamdev</a>)</p><p><a href="https://twitter.com/FlutterComm">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ece660e19c91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-bouncing-button-animation-ece660e19c91">Flutter — Bouncing button animation</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 — Effectively scale UI according to different screen sizes]]></title>
            <link>https://medium.com/flutter-community/flutter-effectively-scale-ui-according-to-different-screen-sizes-2cb7c115ea0a?source=rss-b2723c3a8722------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cb7c115ea0a</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Daniele Cambi]]></dc:creator>
            <pubDate>Sat, 18 May 2019 22:01:00 GMT</pubDate>
            <atom:updated>2019-05-25T22:14:38.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Effectively scale UI according to different screen sizes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMOh7JwiTAVVHF8e7sijNg.png" /></figure><h4>What is Flutter?</h4><p>If you are here, you probably already have a good enough understanding of what Flutter is, the most important aspect that you’ve got to keep in mind while reading through this article, is that Flutter allows us to have full control of every single pixel displayed on the screen.</p><h4>What’s this article about?</h4><p>Since we have full control on all the pixels, we might want to draw a rectangle like this.</p><pre>Container(<br> height: 40,<br> width: 60,<br>),</pre><p>Great! We have a rectangle, but now, look at what happens if we display it on an iPhone 5s (4&quot; Display) and on an iPhone XS Max (6,46&quot; Display).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCggAyRem4cLs68OjCie_g.png" /></figure><p>As you may noticed from the images above, the rectangle shown on the iPhone Xs Max is way smaller than the one displayed on the iPhone 5s.</p><p>That’s because Flutter won’t question whether the app is running on an iPhone 5s, an iPhone Xs Max or even a 13&quot; iPad, the container will always be 40 x 60.</p><h4>I got it, but how can I fix it?</h4><p>Let’s solve the problem in a visual way first, then, once it is clear, we’ll get to the code.</p><p>Let’s take an empty view and then add a grid to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9y6-vDPgfbFUxP7u6oqIiw.png" /></figure><p>Now, we are going to refer to the cells of the grid as “<strong>Blocks</strong>”</p><p>Finally we set the height and width of our rectangle using the blocks. This will allow us to have a consistent UI across every single display size, from an iPhone 5s to an iPad because for both of them we are going to have a 100 x 100 grid.</p><h4>Let’s get to the code implementation!</h4><p>Start creating a new dart file called ‘size_config.dart’, within it, define the SizeConfig class.</p><pre>import ‘package:flutter/widgets.dart’;<br> <br>class SizeConfig {}</pre><p>We need to import ‘widgets.dart’ in order to use a very convenient class in Flutter that’s called <strong>MediaQueryData</strong> which holds the information of the current media, among which there is the size of our screen.</p><p>Now let’s define the properties we are going to use in this class.</p><pre>import ‘package:flutter/widgets.dart’;</pre><pre>class SizeConfig {<br> static MediaQueryData _mediaQueryData;<br> static double screenWidth;<br> static double screenHeight;<br> static double blockSizeHorizontal;<br> static double blockSizeVertical;<br>}</pre><p>We need to initialize those values by writing a constructor function.</p><pre>class SizeConfig {<br> static MediaQueryData _mediaQueryData;<br> static double screenWidth;<br> static double screenHeight;<br> static double blockSizeHorizontal;<br> static double blockSizeVertical;<br> <br> void init(BuildContext context) {<br>  _mediaQueryData = MediaQuery.of(context);<br>  screenWidth = _mediaQueryData.size.width;<br>  screenHeight = _mediaQueryData.size.height;<br>  blockSizeHorizontal = screenWidth / 100;<br>  blockSizeVertical = screenHeight / 100;<br> }<br>}</pre><p>And this is pretty much it, all that’s left to do is to instantiate this object in your home screen.</p><pre>class HomeScreen extends StatelessWidget {<br> <a href="http://twitter.com/override">@override</a><br> Widget build(BuildContext context) {<br> SizeConfig().init(context);<br> …<br> }<br>}</pre><p>Finally use it to set the width and height of your container.</p><pre><a href="http://twitter.com/override">@override</a><br>Widget build(BuildContext context) {<br> return Center(<br>  child: Container(<br>   height: SizeConfig.blockSizeVertical * 20,<br>   width: SizeConfig.blockSizeHorizontal * 50,<br>   color: Colors.orange,<br>  ),<br> );<br>}</pre><p>In the end we are basically saying that the rectangle should be 50% of the screen in width and 20% of the screen high.</p><p>And that’s pretty much all! This is the rectangle shown on an iPhone 5s and an iPhone XS Max.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYPDcboNdph7ZgIMiIFAiw.png" /></figure><h4>Expanding on this concept</h4><p>If you are a more experienced Flutter developer you may already have dealt with notches, status bars, navigation bars and all this stuff.</p><p>There’s a really convenient widget in flutter to deal with those in an efficient way, it is called ‘SafeArea’.</p><h4>How do we account for SafeArea in our grid?</h4><p>We start by adding a couple of fields into out ‘SizeConfig’ class to calculate the space taken by the SafeArea and remove it from the grid.</p><pre>class SizeConfig {<br> static MediaQueryData _mediaQueryData;<br> static double screenWidth;<br> static double screenHeight;<br> static double blockSizeHorizontal;<br> static double blockSizeVertical;<br> <br> static double _safeAreaHorizontal;<br> static double _safeAreaVertical;<br> static double safeBlockHorizontal;<br> static double safeBlockVertical;<br> <br> void init(BuildContext context) {<br> _mediaQueryData = MediaQuery.of(context);<br> screenWidth = _mediaQueryData.size.width;<br> screenHeight = _mediaQueryData.size.height;<br> blockSizeHorizontal = screenWidth / 100;<br> blockSizeVertical = screenHeight / 100;<br> <br> _safeAreaHorizontal = _mediaQueryData.padding.left + <br> _mediaQueryData.padding.right;<br> _safeAreaVertical = _mediaQueryData.padding.top +<br> _mediaQueryData.padding.bottom;<br> safeBlockHorizontal = (screenWidth -<br> _safeAreaHorizontal) / 100;<br> safeBlockVertical = (screenHeight -<br> _safeAreaVertical) / 100;<br> }<br>}</pre><p>This will allow you to effectively scale the UI without worrying about the SafeArea.</p><h4>What about scaling text?</h4><p>Turns out you can use this very same grid for scaling text, I normally scale it using the SizeConfig.safeBlockHorizontal, but you can do it with the vertical one as well.</p><p>Here’s how it looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*N7uiIWnnF28K39EwpdQkLA.png" /></figure><h4>GitHub link for the code shown in this article</h4><p>All the code I have put in this article along with examples on how to use it, are available at</p><p><a href="https://github.com/dancamdev/effectively_scale_UI_according_to_different_screen_sizes">https://github.com/dancamdev/effectively_scale_UI_according_to_different_screen_sizes</a></p><h4>Conclusion</h4><p>So, this has been my very first article ever. I hope you enjoyed the article and most importantly, I hope you used what you’ve learned here to make many awesome, well scaled apps!</p><h4>Who are you and where can I contact you?</h4><p>You can find me on</p><p>- Instagram: Daniele Cambi (<a href="https://www.instagram.com/dancamdev/">https://www.instagram.com/dancamdev/</a>)<br>- Twitter: <a href="http://twitter.com/dancamdev">@dancamdev</a> (<a href="https://twitter.com/dancamdev">https://twitter.com/dancamdev</a>)<br>- Email: <a href="/service/mailto:dancam.dev@gmail.com">dancam.dev@gmail.com</a></p><p>Daniele Cambi (<a href="http://twitter.com/dancamdev">@dancamdev</a>)</p><p><a href="https://twitter.com/FlutterComm">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cb7c115ea0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/flutter-effectively-scale-ui-according-to-different-screen-sizes-2cb7c115ea0a">Flutter — Effectively scale UI according to different screen sizes</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>